Blaze - Arguments with if/else

Just a quick question:

Wasn’t there a way in blaze to use if else without writing a helper?

E.g. something like this:

The includes:

{{> card type=box}}
{{> card }}
{{> card }}

The template:

<template name="card">
  {{#if type=box}}
	a box
  {{/if}}
  something else
</template>

When I’m implementing it like this every instance of {{> card }} shows the “a box” content.

Do you mean {{#if type=="box"}}?

1 Like

Take a look at https://github.com/raix/Meteor-handlebar-helpers

It has a nice helper called $eq that lets you do simple comparisons like this.

If you are just checking to see if the value exists, you could do something simple like:

{{#if type}}
  a box
{{else}}
  something else
{{/if}}