Sajith
Sajith

Reputation: 106

Compile a dust template that has an index helper

I am trying to compile a dust template that has an index helper ({@idx}{.}{/idx}) using grunt-dust. For some reason, the helper is not getting evaluated. Is there an explicit step to enable helpers in the Gruntfile? My Gruntfile configuration has dust.options.wrapper set to false.

<ul>
   {#day.hours}
   <li id="id{@idx}{.}{/idx}" >
      <div>{startTime} {@idx}{.}{/idx}</div>
   </li>
   {/day.hours}
</ul>

Upvotes: 1

Views: 417

Answers (2)

kate2753
kate2753

Reputation: 136

grunt-dust task generates dust-runtime.js file which includes dust-core.js only.

In order for helpers to work you need to include dust-helpers.js along with dust-runtime.js (or dust-core.js which is the same as dust-runtine.js).

Note, dust-helpers needs to be included during render time only, no need to include it for compilation.

Upvotes: 1

prashn64
prashn64

Reputation: 657

I haven't tried using grunt-dust myself, but you could try using $idx instead of {@idx}{.}{/idx}

This is a quick solution, but I'll look into why grunt-dust doesn't evaluate helpers.

Upvotes: 0

Related Questions