I want to create a Handlebars helper that will allow me to show an element x
number of times, with the value of x
determined by the data passed to the template.
I came across some code on this page that uses the #times
function. However, instead of the loop running a set number of times in each template, I would like to adjust it based on the data provided.
For example, if I pass {stars: 50}
into this template, I expect to see 50 stars printed.
{{#times {{stars}} }}★{{/times}}
Unfortunately, this syntax triggers a parse error during template compilation.
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'ID', 'DATA', 'SEP', got 'OPEN'
Is there a way for me to enable my helpers to accept dynamic input?