Skip to main content
March 1, 2018
Répondu

null my.token?

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

Ce sujet a été fermé aux réponses.
Meilleure réponse par 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

}

4 commentaires

SanfordWhiteman
Level 10
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
Level 10
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

}