DRY with *haml_coffee_assets* and partials
https://github.com/netzpirat/haml_coffee_assets
You can render partial templates with hamlcoffeeassets. It is very simple to use:
In first file (/template/index.jst.hamlrc):
%p Lorem ipsum...
%ul
- for @word in ['Sample', 'text', 'string']
%li!= JST['path/to/partial'](class: 'red_text', word: @word)
In partial (/path/to/partial.jst.hamlc):
%span{class: @class}= @word
Result:
<p>Lorem ipsum...</p>
<ul>
<li><span class='red_text'>Sample</span></li>
<li><span class='red_text'>text</span></li>
<li><span class='red_text'>string</span></li>
</ul>
Written by Alexander Kirillov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
iam4x
94.17K
ericdfields
63.02K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#