Search code examples
rubyhamlmustache

Set attributes in haml using variable in mustache


I'm using both haml and mustache for frontend. There is a code snippet:

.module-subtitle
  {{title}}

I want to show a tooltip for .module-subtitle with title attribute, using the content inside {{title}}. I tried

.module-subtitle{ :"title" => {{title}}}
  {{title}}

but it didn't work as it has syntax error. Any hints?


Solution

  • You could use :plain, something like this:

    :plain
      <div class="module-subtitle" title="{{title}}">
        {{title}}
      </div>