Related Tags:
JQuery JQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. Learn More, JavaScript Javascript is an object-oriented computer programming language commonly used to create interactive effects within web browsers. Learn More, HTML Hypertext Markup Language, a standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages. Learn More, mustache.js mustache.js is an implementation of the mustache template system in JavaScript. Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values. Learn More,

how to check for null value while rendering my html using mustache.js ?

Description:For example I need to render conditional Image tag,


if( {{ImagePath}} != null ) {
<img src="{{ImagePath}}"/>
}
else{
<img src="Some static path"/>
}

Posted by: | Posted on: Dec 13, 2018

1 answers

Replies

5

you can easily achieve this while working with mustache.js by using the following code.(Note: specially look at the "#" and "^" symbols in the code)

{{#ImagePath}}
<img src="{{ImagePath}}"/>
{{/ImagePath}}
{{^ImagePath}}
<img src="/images/No-Image.png"/>
{{/ImagePath}}

Replied by: | Replied on: Dec 14, 2018



Reply
×

Code block Hyperlink bold Quotes block Upload Images

Preview