Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistencies in precompiled templates - missing sections #452

Closed
brettcave opened this issue Feb 25, 2013 · 7 comments
Closed

Inconsistencies in precompiled templates - missing sections #452

brettcave opened this issue Feb 25, 2013 · 7 comments

Comments

@brettcave
Copy link

We have an issue when using handlebars precompilation. In the HTML code, we have snippets within handlebars operators, and some snippets just don't get included in the resulting precompiled template. The HTML has a relatively large amount of content, with lots of operators. Here's a small section of the HTML:

{{#if isGeneric}}
<td class="description">{{productName}}</td>
{{else}}
<td class="description"><p id="{{productId}}" isGeneric="{{isGeneric}}" productType="{{productType}}" class="bluetext productid_opener">{{description}}</p>
<td class="something">{{productName}}</td>
{{/if}}
{{#if isGeneric}}
<!-- SEARCH FOR ME-->
<td class="empty">&nbsp;</td>
<td class="empty">&nbsp;</td>
<td class="description">{{productName}}</td>
<!-- THE END FOR ME-->
{{else}}
<td class="description"><p id="{{productId}}" isGeneric="{{isGeneric}}" productType="{{productType}}" class="bluetext productid_opener">{{description}}</p>
<td class="something">{{productName}}</td>
{{/if}}

If I search through the precompiled template, I can't find "SEARCH FOR ME" - the comment is never included in the template. (This is happening in random places in our code, and isn't really that easy to trace). However, if we don't use precompilation and use client-side compilation, then it works fine. We precompile in node.js using a custom script as such:

var template = Handlebars.precompile(html);

template is then written to a JS file which is served to the client (which is missing the comment).

@brettcave
Copy link
Author

I have also tested this by saving the HTML to a file, installing handlebars globally (npm install handlebars -g) and then running handlebars template.html -f template.js and am still missing the 2nd function.

@kpdecker
Copy link
Collaborator

This is a dupe of #428 which is fixed in master. I hope to roll a tagged npm release this evening to fix this issue.

@brettcave
Copy link
Author

thanks kpdecker.

@brettcave
Copy link
Author

hi, any update on that roll ?

@kpdecker
Copy link
Collaborator

Sorry, this slipped through the cracks. I just pushed 1.0.10. Let me know if this is still failing for you.

@brettcave
Copy link
Author

great news :) thank you. We are updating version now and kicking off a build, and will let you know.

@brettcave
Copy link
Author

kpdecker, we have upgraded handlebars to 1.0.10 and confirm that the nested if issue is resolved (it's being used in a relatively complex handlebars template, with up to 5 levels of nested conditions in each / if / else structures).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants