SOLVED

Velocity Token Nesting

Go to solution
Jay00031987
Level 4

Velocity Token Nesting

I have created two velocity token and calling one velocity token into another but after debug it print plain format i.e. {{my.VTL-1}} only. 

My Velocity token script -2 is below given, {{my.VTL-1}}, {{my.VTL-2}}

 

 

 

#if( $test_cList.isEmpty() )
#set( $DEFAULT = 0 )
#else
{{my.VTL-1}}
#end

 

 

Below is dummy VTL-1 script 

 

 

#set( $DEFAULT_VTL = 1 )
$DEFAULT_VTL

 

What is the correct format to call one VTL token into another one?

Jay
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token Nesting

You can't literally put Velocity tokens inside Velocity tokens.

 

You set a Velocity variable ($reference) in one token, then access that variable inside a subsequent token.

 

All Velocity code shares a single scope, executed from top to bottom. So if {{my.token1}} is included before {{my.token2}} then {{my.token2}} can access all variables from {{my.token1}}.

 

 

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token Nesting

You can't literally put Velocity tokens inside Velocity tokens.

 

You set a Velocity variable ($reference) in one token, then access that variable inside a subsequent token.

 

All Velocity code shares a single scope, executed from top to bottom. So if {{my.token1}} is included before {{my.token2}} then {{my.token2}} can access all variables from {{my.token1}}.