handlebars-loader
handlebars-loader copied to clipboard
Helpers for entire code blocks?
Hi
I hope it's ok that I'm asking here because I have little hope of getting help on StackOverflow for this specific of a question.
I checked the helpers example and have not found out how I would invoke a helper for an entire block of code, only for a text, like so:
{{[transformers/embiggen] 'This should have asterisks'}}
Here's my helper, to do something x times:
module.exports = function(n, block) {
var accum = '';
for(var i = 0; i < n; ++i)
accum += block.fn(i);
return accum;
}
And here is how it would normally look in a template:
<div class="clndr-days">
{{#times 7}}
<div class="week">
other code
{{#other_nested_helper}}
<div>
more code
</div>
{{/other_nested_helper}}
</div>
{{/times}}
</div>
Can I achieve this with the syntax of this loader?
If not - can I define a helper before templates are loaded and parsed? Or can I reparse a template with Handlebars (without including a text-loader and requesting the module as text)?
Thanks for help on this.
I used this syntax and it works:
{{#[helper/myhelper] firstarg secondarg}}
<div>my block {{variable}}</div>
{{/[helper/myhelper]}}