Search code examples
rubyhamltailwind-css

Fractional classes with Tailwind CSS inside a HAML file


I am trying to use the w-2/3 class from Tailwind CSS with HAML in a Rails .html.haml file. The forward slash is causing Rails (or HAML) to throw an exception and I don't know how to format it so it's accepted.

Is there a way to use the w-2/3 etc classes or will I have to go back to using .html.erb?


Solution

  • You will have to explicitly add the class, something like

    %div{:class => "w-2/3"}
    

    Note you can combine this with the shorthand syntax for classes if you want, e.g.

    .foo{:class => "w-2/3"}