Handlebars {{#if}} {{elseif}}阻止助手无法正常工作

时间:2017-10-19 17:24:43

标签: html json css3 handlebars.js

我使用handlebars.js解析复杂的json 如果它们匹配基于json的条件,我想以不同的样式显示。 所以json如下:

    "TradeLine":{  
             "TradeLine":{  
                "Mortgage Accounts":[  
                   {  
                      "SubscriberDisplayName":"SAVINGS AND LOAN COMPA",
                      "Evaluation":"N",
                      "EvaluationDesc":"Closer review is required",                      
                      "KOB":"Savings And Loan Companies",                     
                      "RevolvingOrInstallment":"I",
                      "RevolvingOrInstallmentDesc":"Installment",
                      "OpenOrClosed":"C",
                      "OpenOrClosedDesc":"Closed",
                      "Status":"05",
                     }
                     ]
             }
    }

我已按照以下链接

Block Helper Link referred

Second referred Link

我想做的是评估是否为" N" (否定)然后displayname应该有" *"除了它的名称,如果它是" P" (正面)它应该按原样显示。 我怎样才能做到这一点 ? 我的HTML代码就像这样

<thead class="thead-default">
                          <tr>
                            {{#if '"Evaluation" == "N"'}}
                            <th colspan="4" scope="colgroup"> {{SubscriberDisplayName}} * </th>
                            {{elseif '"Evaluation" == "P"'}}
                            <th colspan="4" scope="colgroup"> {{SubscriberDisplayName}}</th>
                            {{/if}}
                          </tr>
                          </thead>

提前致谢

1 个答案:

答案 0 :(得分:0)

通过以下代码解决了上述问题:

{{#if_eq Evaluation "P"}}
    <th colspan="4" scope="colgroup"> {{SubscriberDisplayName}}</th>
{{else}}
    <th colspan="4" scope="colgroup" style="color:red"> {{SubscriberDisplayName}}*</th>
{{/if_eq}}