简体   繁体   中英

Handlebars {{#if}} {{elseif}} block helper not working

I am parsing complex json using handlebars.js I want to display to name in different style if they matches a condition based on the json. So the json is as follows :

    "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",
                     }
                     ]
             }
    }

I have followed the below links

Block Helper Link referred

Second referred Link

What i want to do is if the Evaluation is "N" (Negative) then displayname should have "*" besides it name and should be colored RED else if it's "P" (Positive) it should be displayed as it is. How can i do that ? My HTML Code is like this

<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>

Thanks in advance

Solved the above problem by below code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM