You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Stan Devyatovsky <st...@devyatovsky.com> on 2004/08/26 18:46:43 UTC
Capture directive
Hello,
Velocity has "set" directive:
#set($a = "text text text")
Now is there something like #capture directive in Velocity?
#capture($a)
text text
multiline text
<html tags here... />
#end
So that $a variable would be assigned the content between "capture"
and "end"?
--
Best regards,
Stan mailto:stan@devyatovsky.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re[2]: Capture directive
Posted by Stan Devyatovsky <st...@devyatovsky.com>.
Hello Nathan,
Thanks for the info, Nathan! I will try searching the archive.
Still, I think this directive would be worth including it in official
package. I think it should be not difficult to implement.
>> Velocity has "set" directive:
>> #set($a = "text text text")
>>
>> Now is there something like #capture directive in Velocity?
>>
>> #capture($a)
>> text text
>> multiline text
>> <html tags here... />
>> #end
>>
>> So that $a variable would be assigned the content between "capture"
>> and "end"?
NB> there's nothing official, but there have been a few custom directives that do
NB> this posted over the years. it seems to me there was one posted about a year
NB> ago or so that was called #define and works like yours below. try searching
NB> the archives for it. if you can't find it, i think i still have a copy saved
NB> somewhere and i can repost it.
NB> oh, and i'm pretty sure that the current CVS HEAD of velocity supports line
NB> breaks in #set() statements, so you could do:
NB> #set( $a = "
NB> text text
NB> multiline text
NB> <html tags here... />
NB> " )
NB> but that's a slightly different thing functionally.
NB> Nathan Bubna
NB> nathan@esha.com
NB> ---------------------------------------------------------------------
NB> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
NB> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
--
Best regards,
Stan mailto:stan@devyatovsky.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Capture directive
Posted by Nathan Bubna <na...@esha.com>.
Stan Devyatovsky said:
> Velocity has "set" directive:
> #set($a = "text text text")
>
> Now is there something like #capture directive in Velocity?
>
> #capture($a)
> text text
> multiline text
> <html tags here... />
> #end
>
> So that $a variable would be assigned the content between "capture"
> and "end"?
there's nothing official, but there have been a few custom directives that do
this posted over the years. it seems to me there was one posted about a year
ago or so that was called #define and works like yours below. try searching
the archives for it. if you can't find it, i think i still have a copy saved
somewhere and i can repost it.
oh, and i'm pretty sure that the current CVS HEAD of velocity supports line
breaks in #set() statements, so you could do:
#set( $a = "
text text
multiline text
<html tags here... />
" )
but that's a slightly different thing functionally.
Nathan Bubna
nathan@esha.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org