Have payload and want to check that {{data.channels}} contains no sub elements. Is there a handlebar to do that?
{
“data”: {
“channels”: {
}
}
I know how to check for null: {{data.channels}} != null.
Using in a conditional block.
Have payload and want to check that {{data.channels}} contains no sub elements. Is there a handlebar to do that?
{
“data”: {
“channels”: {
}
}
I know how to check for null: {{data.channels}} != null.
Using in a conditional block.
Can use {{length val}}
Yup, you got the right idea. {{length val}}
will print out the number of keys if val
points to an object.
In an expression, this would return true
…
{{length val}} === 0
And in a string template, you could conditionally render content like so …
{{#eq (length val) 0}}empty{{else}}not empty{{/eq}}