Having trouble with the Handlebars {{#if}} and {{elseif}} block helpers not functioning properly?

When working with handlebars.js, I am faced with the task of parsing complex JSON and displaying names in different styles based on certain conditions. The JSON structure 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 found some helpful resources that I followed:

Block Helper Link referred

Second referred Link

My goal is to add an asterisk next to the display name and color it red if the Evaluation is "N" (Negative), otherwise display it as it is. Here is a snippet of my HTML code:

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

Any insight or advice on how to achieve this would be greatly appreciated. Thank you!

Answer №1

Resolved the issue by utilizing the following code snippet:

{{#if_eq Condition "P"}}
    <th colspan="4" scope="colgroup"> {{UserDisplayName}}</th>
{{else}}
    <th colspan="4" scope="colgroup" style="color:green"> {{UserDisplayName}}*</th>
{{/if_eq}}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to generate a unique bootstrap card for every piece of submitted data?

I am trying to figure out how I can create a dynamic bootstrap card for each submitted data. When the form is submitted, a new card will be created and the data will be stored in that card. Each piece of data will be displayed in a column format similar to ...

Centralize Navigation Dropdowns in Bootstrap 4

I am currently using Bootstrap 4 to craft a navigation menu. Each navigation item features a dropdown menu that I want to display centered horizontally on the page, with the same size as the ul element. However, due to my limited experience with Bootstrap, ...

Find the tableid in the response function utilizing the Google Visualization API

Seeking assistance from anyone who can point me in the right direction. I've been struggling with this issue for days and can't seem to make any progress. I'm relatively new to working with JSON, objects, Google Visualization, etc. Essential ...

Scrolling to specific ID scrolls only in a downward direction

I have been using fullpage.js for my website and I am facing an issue. When I create a link and connect it to an id, everything works perfectly. However, I am unable to scroll back up once I have scrolled down. Here is the HTML code: <a href="#section ...

Tips for maintaining the backslash character while transforming a string into a regular expression

Received some regular expressions in a JSON object like this: { config: { regEx: "/^$/" } } Attempting to convert the string into a regex: const re = new RegExp(config.regEx); The issue is that RegExp escapes the / characters resulting in //^$ ...

In Javascript, POST tags are not conveyed within a single sentence

When there are multiple tags in the same sentence, only the first selected tag is being sent. What could be causing this issue? Check out the code on JSFiddle $(function(){ $('#lbl1').one('mouseover', functio ...

What is the best way to have several automatic slideshows on a single webpage?

Currently, I am exploring the W3 HTML/CSS tutorial on incorporating multiple slideshows into a single page. While the tutorial provides examples for manual navigation of multiple slideshows or a single automatic slideshow, it lacks guidance on setting up m ...

Update the href property in the provided JSFiddle code to enable the integration of YouTube videos with Fancybox

After upgrading from Fancybox 1.3.4 to Fancybox 2.1.4, I've encountered issues with the href property not working correctly with my YouTube videos. If you could take a moment to review this functioning jsfiddle that I'm attempting to edit. Esse ...

What's the most effective approach to verify if all visible input fields possess a value? (excluding the use of jQuery validator

In order to ensure that all necessary fields are selected, I need to implement a check upon clicking a button. Below is the HTML code: <input type="text" class="required-entry"> <input type="text" class="required-entry"> <input type="text" ...

The HttpMessageNotWritableException is throwing an error in the Corda framework

Encountering an issue when trying to retrieve node information using a method in Java with a Spring web server. Below is the code snippet written in a custom controller: @RequestMapping(value="/me", produces = MediaType.APPLICATION_JSON) public Part ...

Using React Native to extract and store JSON data in a state variable

There are two files located in the same directory: Detail.json Base.js Detail.json contains the following data: [ { "id": 1, "name": "A", }, { "id": 2, "name": "B", }, { "id": 3, "name": "C", } ]; Base.js is structu ...

Expanding Images in Bootstrap 4 Carousel

I am encountering some difficulties with a basic carousel implemented using Bootstrap 4. The carousel contains 3 images with the class d-block w-100, which is supposed to make the images stretch to the full width of the screen. However, in my case, the ima ...

What is the significance of the space between form.validate and .ng-invalid-email.ng-dirty?

I'm currently working on an AngularJS application and I'm confused about the spacing between "form.validate" and ".ng-invalid-email.ng-dirty" in the stylesheet code below: <style> form.validate .ng-invalid-required.ng-dirty {background ...

Looking for data in PostgreSQL using JSON structure

As I consider storing data in a postgres jsonb data type, the structure could look something like {"name": "Jhon Smith", "emails": ["johnsmith@example.com", "j.smith@example.com"], "phones": ["123456789", "987654321"]}. I am aware that I can search this ...

Sending various Python variables to PHP

CSS Below is a simple form where users can input a URL: <form method="post" action="/" accept-charset="utf-8"> <input type="text" name="url" placeholder="Enter a URL" /> <button>Submit</button> </form> PHP (CodeIgn ...

Ensuring consistent column heights in Bootstrap across all devices

There is an HTML element containing an image and text positioned side by side using Bootstrap. Here is the code: <div class="row"> <div class="col-md-6"> <div class="avatar"> <img src="<?= get_template_directory_uri(); ...

Masonry is limited to displaying a single column at a time

Struggling to make masonry work for the first time, as it is only displaying as a single column. Being more of a designer than a developer, it's possible that I'm overlooking something. Here is the code snippet I'm using: <body> ...

Issues with CSS not loading properly on EJS files within subdirectories

This is the structure of my folders (with views located in the root directory): views/contractor/auth/login.ejs When I access that file, the CSS styles are not being applied. The connection to the CSS file, which is located in the public directory in th ...

Navigate through JSON data / adjacent data

Currently, I am iterating through a JSON object and generating a list of links. Check out the fiddle link: http://jsfiddle.net/jasonday/hzZ8j/ Each link is assigned an ID based on the storeID in the JSON data. My goal is to have a function that, when a ...

Confusion between Codeigniter's URL and base_url() function

$config['base_url'] = 'localhost/project'; <link href="<?= base_url(); ?>/css/bootstrap.min.css" rel="stylesheet"> An issue arises with the CSS not loading on the view due to a double '/' in the URL. This occur ...