Could use "else if(){....}" in template?


#1

could I use else if(...........) in the template.


#2

Yep:

{{#if x}}
  hello
{{else}}
  goodbye
{{/if}}

#3

I want to check multiple with else if().....else if()......end


#4

use another template in else part ? :smiley:


#5

You can use standard Handlebars if/else syntax though often a better practice is to use a template helper but this depends on what you’re trying to achieve.


#6

Meteor-jade supports else if branches:

if user.isAdmin
  h1 Hello admin
else if user.isConnected
  h1 Hello user
else
  h1 Hello visitor

which simply desugar to the same tests without the else if, ie:

if user.isAdmin
  h1 Hello admin
else
  if user.isConnected
    h1 Hello user
  else
    h1 Hello visitor

#7

Thanks for all helping.
I should be use

if

else
     if
     else

#8

@theara: See discussion here: https://github.com/meteor/blaze/pull/50