SOLVED

null my.token?

Go to solution
Highlighted
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: null my.token?

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

}

View solution in original post

4 REPLIES 4
Highlighted
Level 10 - Community Moderator

Re: null my.token?

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.

Highlighted
Anonymous
Not applicable

Re: null my.token?

Hi Sanford,

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

Highlighted
Level 10 - Community Moderator

Re: null my.token?

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

}

View solution in original post

Highlighted
Anonymous
Not applicable

Re: null my.token?

Thanks, I may need you magical assistance with this one.