Вопрос

we use handlebars precompiled templates in a web app. one of our elements broke recently - incorrect HTML was being used in a certain location. When looking at the precompiled js, I can see that elements are missing. the HTML that is precompiled is quite large and complex with lots of handlebars operators. Here's a very simplified version:

{{#if isGeneric}}
<!-- SEARCH FOR ME-->
<td class="empty">&nbsp;</td>
<td class="empty">&nbsp;</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}}

This snippet in the HTML is very similar to another snippet (if that makes any difference).

When I precompile this, and search for the HTML in the generated programXX, I can't find the code anywhere (e.g. "SEARCH FOR ME"). I notice that the handlebars programs before and after that specific section of code are numbered with a gap. e.g.:

function program52(depth0,data) { // find elements in the condition just prior to the "if" above }
function program54(depth0,data) { // find elements from HTML in condition just after the "if" above }

so from that I would assume that the function program53 contains the relevant code, but why is it not included in the generated HTML? How does handlebars determine what to include or exclude in the HTML?

Это было полезно?

Решение

I posted https://github.com/wycats/handlebars.js/issues/452, which was actually a dupe of https://github.com/wycats/handlebars.js/issues/428.

The issue is resolved and will be available in npm soon.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top