Issues with @key, @index, @first etc. in grunt-assemble using assemble-handlebars 0.3.0
Closed this issue · 11 comments
Today we've discovered that @key
and also all other @
properties in handlebars don't work in the current version of grunt-assemble
. It looks like assemble 0.4.42
is using assemble-handlebars 0.2.4
(that is relying on Handlebars 1.3) where those properties work but with grunt-assemble > assemble-handlebars@0.3 > Handlebars 3.0.3
@key
and other properties within the each
block aren't working anymore. This can't be a handlebars issue itself as its working with vanilla Handlebars 0.3.1.
You have a clue? I'll also dive deeper once I have some time.
@doowb did you answer an issue about this recently?
I don't think so. I know I've seen some other issues created about this, but I thought that it was fixed by moving to Handlebars 3.
yeah, same here. hmm, we'll need to look into this a little more deeply.
fwiw this kind of issue with handlebars versions is the primary thing that has made me hesitant to merge in the 0.6 branch on handlebars-helpers.
I moved from standard assemble
to grunt-assemble 0.4.0
in my grunt build process and can confirm that @index
, @key
, @first
and @last
do not work in the current version. After going back to standard assemble 0.4.42
everything works fine. Maybe that helps.
Cheers,
Daniel
I just switched over to grunt-assembe@0.4.0 from assemble@0.4.42 and have noticed this as well, does any know a workaround with other existing helpers?
Did you get around this @gionkunz ?
Same problem for me.
grunt-assemble 0.3.1
assemble-handlebars 0.3.0
Same problem here. While I can use Assemble's forEach helper, it seems to fail when used inside a native each helper.
grunt-assemble 0.4.0
assemble-handlebars 0.3.0
I tracked down this issue and I believe it's due to how grunt-assemble passes options into Handlebars. In Handlebars compiler.js
line 469, the data
property is set by default to true
if 'data'
property does not exist in options
. However in grunt-assemble's assemble.js
(line 589), context.data
exists, but its final value is undefined
, meaning that Handlebars will not create data frame for the each helper. And thus calls to @index
, @first
, etc. will not return anything.
Since context.data
is undefined
in my case, I delete context.data
before calling Handlebars's compile method, and the problem goes away. Similarly if I modify Handlebars compiler.js
to set data
to true
when !('data' in options) || options.data === void 0)
, the problem is resolved too.
Do pardon me calling out to @doowb for further opinion.
Any update on this? This issue makes grunt-assemble completely unusable as far as I can see and should have high priority.
grunt-assemble@0.5.0
has been published and the @key
and @index
properties are working in the {{#each}}
helper.