Search code examples
ruby-on-railsruby-on-rails-3slim-lang

Slim Syntax for Inline Div/Table Classes with Embedded Ruby


I have a table defined in slim:

 table
    tr
       td
          =_("Some Content")
       td
          =_("Some Content")

I would like to add some classes to certain td tags. I can do so like this:

 table
    tr
       td.extraclass
          =_("Some Content")
       td
          =_("Some Content")

This adds "extraclass" to that td:

 <td class="extraclass"> Some Content </td>

How can I add a class by embedding some rails/ruby into this? In normal rails I could do:

 <td class="<%=@article.attribute%>">

How do I do this here? I don't think I can do:

        td.=_(@article.attribute)

But I would like to add classes in some similar way here. Anybody have any advice? if I have not been clear in what I'm attempting to do, please let me know what I can add.


Solution

  • The doc for this feature is here:

    td class="#{@article.attribute}"