When building a project with dativejs you might want to conditionally render a tag / anything
Then π€― You might be like
π€ How can I achieve that
Don't worry dativejs has it
That's why we introduced the {{#if}} block
Usage
{{#if isOpen}}
<h1>It's open</h1>
{{/if}}
What if you also need to show some stuffs if the condition value is false
There is also an {{:else}} and {{:else if}}
They work just same as the JavaScript if,else,else if
Usage
{{#if isOpened}}
<h1>π</h1>
{{:else}}
<h1>π</h1>
{{/if}}
You can add the {{:else if}} also
{{#if isOpened}}
<h1>π</h1>
{{:else if isHated}}
<h1>π</h1>
{{:else}}
<h1>π</h1>
{{/if}}
Thanks for reading
Next tutorial will be on the {{#each}} block
Top comments (0)