Results 1 to 2 of 2

Thread: Handlebars.js - Show data only if {{ image_url}} doesn't contain "questionmark"

  1. #1
    Join Date
    Jan 2017
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Handlebars.js - Show data only if {{ image_url}} doesn't contain "questionmark"

    Hi,

    As you can see in this example, which I created on Codepen, some of the data don't have an image and whenever there's no image, a place holder image is shown:

    Handlebars.js Example

    Is there any way in Handlebars.js to say that show the data only if the {{ image_url }} doesn't contain "questionmark"?

    Something like this?

    Code:
    {{#each this}}
    {{#if image_url !contains "questionmark"}}
    
        <li class='list-container'>
          <div class="image-container">
              <img src="{{ image_url }}">
          </div>
          <div class="name-container">
            {{ name }}
          </div>
          <div class='role-container'>{{{ role }}}</div>
        </li>
    
    {{/if}}
    {{/each}}

  2. #2
    Join Date
    Jan 2017
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I couldn't find any solution with Handlebars.js, so I did it in JavaScript

    Code:
    (function removeNoImage() {
      for(let key in data.staff) {
        if(data.staff[key].image_url.indexOf('questionmark') !== -1) {
          delete data.staff[key];
        }
      }
    })();

Similar Threads

  1. Flip Book "Images"... does NOT show up, on "newly" hosted Web Site
    By ggmoss in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 01-10-2013, 01:06 AM
  2. Resolved HTML5 Notepad - "Close Window" doesn't work
    By CyBeRaY in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 03-23-2011, 01:46 PM
  3. Replies: 0
    Last Post: 03-24-2010, 11:00 PM
  4. Replies: 0
    Last Post: 03-06-2009, 06:42 PM
  5. Replies: 2
    Last Post: 08-20-2005, 04:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •