I am using backbone.js on a rails backend with HAML Coffee, which is compiled by haml_coffee_assets. There is some duplication in my templates.
Is there a way to create rails-like partials to dry up my templates?
Addition: Can I do content_for(:something)
in Coffee HAML?
There is no
content_for
helper in Haml Coffee, but you simply can render another template within a template.Without Local Variables
For example, you've a template
test
:You can include it within another template like this:
The trick is to unescape the rendered HTML with
!=
.With Local Variables
To pass local variables, just send them to the
JST
function. If this is your partial (articles/_comments.jst.hamlc
):Then this may be your template: