1

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}

2 Answers2

0

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.

smfoote
  • 5,449
  • 5
  • 32
  • 38
0
{?notes}
  Display HTML
{:else}
  {?errors}
    Display HTML
  {/errors}
{/notes}

should do the trick.

myusuf
  • 11,810
  • 11
  • 35
  • 50