CoffeeKup: Add Class to Elements
CoffeeKup is a very succinct and flexible templating engine to define HTML documents in a less verbose manner. It is based on CoffeeScript.
Unfortunately, the documentation of CoffeeKup I could find was not very clear on how to perform one of the most basic tasks in creating HTML documents:
How do I assign a class to an element?
And here is the answer:
div class: 'myclass', ->
div class: 'nested'
Which will result in the HTML document:
<div class="myclass">
<div class="nested"></div>
</div>
Or in more succinct form:
div 'myclass', ->
div 'nested', ->
Please note the '->' after the declaration of the class for the second div. Without it, CoffeeKup would render 'nested' as text and not as element.
Resources