Velocity Token Nesting | Community
Skip to main content
New Participant
May 27, 2020
Solved

Velocity Token Nesting

  • May 27, 2020
  • 1 reply
  • 2275 views

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?

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

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}}.

 

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
May 27, 2020

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}}.