If I am chaining multiple css classes where the HTML would come out looking like:
<a class="btn primary large">
How would I do this in HAML? These guesses didn't work:
.btn-primary-large
."btn-primary-large"
Multiple classes can be applied to a single element in HTML and they can be styled using CSS. In this article, we will stick to only two classes. But the concepts used in assigning two classes can be extended to multiple classes as well.
HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.
Haml is a markup language that's used to cleanly and simply describe the HTML of any web document, without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ERB, and ASP.
Use dots instead of dashes:
.btn.primary.large
Question didn't specifically ask for a Haml+Ruby solution, but here is one for those who are interested. It uses a literal array.
%a{ class: %w[btn primary large] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With