Javascript 如果车把状况不佳,则车把会出现异常情况

Javascript 如果车把状况不佳,则车把会出现异常情况,javascript,html,handlebars.js,Javascript,Html,Handlebars.js,我有这个把手模板: {{! 1st block }} <div class="price_new"> {{product.price_new}} </div> {{! end 1st block }} {{! 2nd block }} {{#if product.price_new}} <div class="price_new"> {{product.price_new}} </div> {{/if}} {{! end 2nd

我有这个把手模板:

{{! 1st block }}
<div class="price_new">
    {{product.price_new}}
</div>
{{! end 1st block }}

{{! 2nd block }}
{{#if product.price_new}}
<div class="price_new">
    {{product.price_new}}
</div>
{{/if}}
{{! end 2nd block }}
<div class="price_new">
{{foo}}
</div>
{{#if foo}}
<div class="price_new">
{{foo}}
</div>
{{/if}}
{{!第一块}
{{product.price_new}}
{{!结束第一块}
{{!第二块}
{{{if product.price_new}
{{product.price_new}}
{{/if}
{{!结束第二块}
正确呈现模板的第一个块:

<div class="price_new">
    2.225.000
</div>

2.225.000
但是第二个块没有呈现,我认为product.price_new不是null、空、未定义,因为它在第一个块中呈现,它应该使if条件为真值,第二个块应该已经呈现,但第二个块根本没有呈现

我在tryhandlebarsjs.com上使用以下上下文进行了尝试:{“foo”:“bar”}和此模板:

{{! 1st block }}
<div class="price_new">
    {{product.price_new}}
</div>
{{! end 1st block }}

{{! 2nd block }}
{{#if product.price_new}}
<div class="price_new">
    {{product.price_new}}
</div>
{{/if}}
{{! end 2nd block }}
<div class="price_new">
{{foo}}
</div>
{{#if foo}}
<div class="price_new">
{{foo}}
</div>
{{/if}}

{{foo}}
{{{#if foo}}
{{foo}}
{{/if}

输出正确呈现。所以问题是,在第一个模板中,为什么第二个块即使product.price_new=“2.225.000”也不重新设计?请帮助,非常感谢大家

你能把if语句改成if true这样只是为了检查语法/工作是否正确hi,我试过if true,如果false,它们都能正确工作syntax似乎很好,你能在检查条件之前为某个变量分配product.price\u new吗,试试看