velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lawrence.Si...@MSCsoftware.com
Subject Re: render.eval()
Date Tue, 21 Sep 2004 13:21:21 GMT
Let's try this a little differently, so the intent is more obvious.  This 
code is taken from a DVSL #match fragment that outputs Latex.  The lines 
beginning with '%' are Latex comments.

        #set($aString = "")
        #set($render = 
$aString.class.forName("org.apache.velocity.tools.generic.RenderTool").newInstance())
        #set($name = "foo")
        #set($value = "bar")
        % $render.eval($context, '#set($$name = "$value")' )
        % I want to see 'bar' here: $foo
        % FYI: \$context is $context

When run on suitable input, the output of this fragment is:

                                                 % $render.eval($context, 
'#set($$name = "$value")' )
                 % I want to see 'bar' here: $foo
                 % FYI: $context is 
org.apache.tools.dvsl.Transformer@1892b4e


Larry Siden, IBS consultant, Viper team
x72612



Shinobu Kawai <shinobu.kawai@gmail.com> 
09/20/2004 06:23 PM
Please respond to
"Velocity Users List" <velocity-user@jakarta.apache.org>


To
Velocity Users List <velocity-user@jakarta.apache.org>
cc

Subject
Re: render.eval()






Hi Larry,

> Why doesn't the following work while I'm running DVSL?:
> 
>         #set($aString = "")
>         #set($render = 
> 
$aString.class.forName("org.apache.velocity.tools.generic.RenderTool").newInstance())
> 
>       #foreach($param in $params)
What's in $params?

>         #set($name = $param.attrib("name"))
>         #set($value = $o.get($name))
What's in $o?

>           ##set($s1 = "#set($$name = '$value')")
Are you deliberately commenting here?

>           % $render.eval($context, '#set($$name = "$value")' )
>           % $render.eval($context, "$name = $$name")
>         #end
> 
> It prints 
> 
>  % $render.eval($context, '#set($$name = "$value")' )
>  % $render.eval($context, "$name = $$name")
And last but most important, how do you want it to print?

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai(shinobu.kawai@gmail.com)

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message