I found a very useful for loop from this SO answer
It works well, but my code seems to lose context to the variable being passed to the partial when I use it. Is there a way that I can pass the "assessmentType" variable so that it continues on inside of this helper? I have the exact thing working just fine outside of this loop but it seems to lose context completely inside of it. The context of "this" now belongs to the index number that the for loop is returning so I can't use that.
// for loop helper
hbs.registerHelper('for', (from, to, block) => {
var accum = '';
for (var i = from; i < to; i++) {
accum += block.fn(i);
}
return accum;
});
// helper that takes in the assessment type
// and returns a path to a png file that I have
hbs.registerHelper("assessment_path", (assessmentType) => {
if (assessmentType === "Leadership") return "leadership/Leadership";
if (assessmentType === "Human") return "human/Human"
})
{{!-- partial --}}
{{> intro assessmentType="Leadership"}}
{{!-- where the variable is being used--}}
{{#for 0 20 }}
<div class="page">
<img src="/img/{{{assessment_path assessmentType}}}_intro_{{this}}.png">
</div>
{{/for}}