null my.token? | Community
Skip to main content
March 1, 2018
Solved

null my.token?

  • March 1, 2018
  • 1 reply
  • 2079 views

Hi All,

A use case has come up where sometimes I will have a circumstance where a token is required to have a null value. In this case it is a text token. As we know the token must be pre-pouulated so is there are way with script that if the value = 00 then display nothing within the assets.

Thanks in advance

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

OK, on the Text {{my.token}} side, how about just store an HTML comment:

<!-- -->

If you're just plopping the token into your HTML, this will be fine.

If you're embedding in JS then you can still check for that specific value, it just won't be "magic":

if ( "{{my.token}}" != "<!-- -->" ) {

  // it's not empty

}

1 reply

SanfordWhiteman
New Participant
March 1, 2018

A Velocity token is implicitly emptyable, since it can just contain a comment

##

I'd just use a Velocity token instead of a Text token.

March 1, 2018

Hi Sanford,

Makes sence although I do need it to render on LP as well.

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 1, 2018

OK, on the Text {{my.token}} side, how about just store an HTML comment:

<!-- -->

If you're just plopping the token into your HTML, this will be fine.

If you're embedding in JS then you can still check for that specific value, it just won't be "magic":

if ( "{{my.token}}" != "<!-- -->" ) {

  // it's not empty

}