Re: Can a directive contain a directive?

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thursday, April 15, 2010, 11:45:09 PM, Jake Ochs wrote:

> Let's say I have variable A that contains the name of another variable
> on the hash tree, say. "B." I'd like to use a to read the value of B so,
> for example, if B contained "C" I could tell Freemarker to output C 
> using A: ${${A}} should result in the output of "C". Naturally, this 
> doesn't work, but is there a way to accomplish this in FTL?

Use the .vars special variable, which is a hash (map) of the
variables, and hence you can use the aHash[aKeyExpression] syntax:

  ${.vars[A]}

A note regarding the FreeMarker terminology: ${something} is called an
interpolation, not a directive. A directive is something like
<#something> or <@something>.

> Thanx in adv.
>
> cross-post on stackoverflow: 
> http://stackoverflow.com/questions/2648933/can-a-freemarker-directive-contain-a-directive
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.