2

I'm using this handlebars loader for webpack.

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 any help on this.

Christof
  • 3,777
  • 4
  • 37
  • 49

0 Answers0