LearnFast.Ninja

Mustache if statement

Example of if statement in mustache.

JavaScript

if (user) {

     

}


Mustache

{{#user}}


{{/user}}


JavaScript

if (user) {

      if (picture) {

            //<img src="{{picture}}"/>
      }
     
else {

            //<img src="/images/default_picture.png" />

      }

}


Mustache

{{#user}}
  {{#picture}}
   
<img src="{{picture}}"/>
  {{/picture}}

  {{^picture}}
   
<img src="/images/default_picture.png" />
  {{/picture}}

{{/user}}


Tags

mustache

if else