
Enter a search term above to see results...
Enter a search term above to see results...
Logical helpers provide utilities for conditional checks and logical operations in templates.
Checks if a value is empty.
Note: empty includes falsey values like
false
,0
undefined
etc.
{#if isEmpty collectionToCheck} Collection is empty{/if}
Name | Type | Description |
---|---|---|
a | any | The value to check |
boolean
- true
if the value is empty, false
otherwise.
{#if isEmpty user.posts} <p>You haven't made any posts yet.</p>{else} <ul> {#each user.posts} <li>{this.title}</li> {/each} </ul>{/if}
Checks if a value is not empty.
Note: the same conditions as
isEmpty
apply, all falsey values will returnfalse
{#if exists valueToCheck} Value exists{/if}
Name | Type | Description |
---|---|---|
a | any | The value to check |
boolean
- true
if the value is not empty, false
otherwise.
{#if exists user.name} <p>Welcome, {user.name}!</p>{else} <p>Welcome, guest!</p>{/if}
Checks if an array has any elements.
{#if hasAny arrayToCheck} Array has elements{/if}
Name | Type | Description |
---|---|---|
a | array | The array to check |
boolean
- true
if the array has elements, false
otherwise.
{#if hasAny searchResults} <ul> {#each searchResults} <li>{this.title}</li> {/each} </ul>{else} <p>No results found.</p>{/if}
Checks if both a and b are truthy.
{#if both conditionA conditionB} Both conditions are true{/if}
Name | Type | Description |
---|---|---|
a | any | First value to check |
b | any | Second value to check |
boolean
- true
if both values are truthy, false
otherwise.
{#if both isLoggedIn hasPermission} <button>Perform Action</button>{else} <p>You don't have permission to perform this action.</p>{/if}
Checks if either a or b is truthy.
{#if either conditionA conditionB} At least one condition is true{/if}
Name | Type | Description |
---|---|---|
a | any | First value to check |
b | any | Second value to check |
boolean
- true
if either value is truthy, false
otherwise.
{#if either isAdmin isModerator} <button>Edit Content</button>{else} <p>You don't have permission to edit this content.</p>{/if}
Returns trueExpr if expr is truthy, falseExpr otherwise.
{maybe condition 'True result' 'False result'}
Name | Type | Description |
---|---|---|
expr | any | The expression to evaluate |
trueExpr | any | Value to return if expr is truthy |
falseExpr | any | Value to return if expr is falsy |
The value of trueExpr
if expr
is truthy, falseExpr
otherwise.
<p>The light is {maybe isOn 'on' 'off'}.</p>