I need to write logic to check whether the value is empty or it has string. Any help on this.. i tried this following. but it doesn't work in nodejs and throwing error
{@if cond="'{notes}' != '' || '{errors}' != '' "}
display html
{/if}
I need to write logic to check whether the value is empty or it has string. Any help on this.. i tried this following. but it doesn't work in nodejs and throwing error
{@if cond="'{notes}' != '' || '{errors}' != '' "}
display html
{/if}
The @if
helper is deprecated and should not be used. However, based on the code you've given, you should probably be able to use an exists check.
{?notes}
{?errors}
{! Display HTML !}
{/errors}
{/notes}
If that doesn't work for some reason, you could use the @ne
helper.
{@ne key=notes value=""}
...
{/ne}
If that still isn't good enough, you could try writing a context helper. The documentation on dustjs.com is excellent.
{?notes}
Display HTML
{:else}
{?errors}
Display HTML
{/errors}
{/notes}
should do the trick.