Dario Liberman wrote:
Thank you for your prompt response Bill,
You're welcome.
How exactly do I write this directive?
In Java. See the existing directives in the source.
I dont undestand how it would be used... Is it instead of the #macro directive???
Yes. You would write an application specific directive to solve a particular problem.
Also the parsing of macros right now does not include the '#end' tag, it is like a simple line directive. Do you think it would be posible to diferentiate macros defined with a new directive (say #macrowb -a macro with body) that assigns to its macros the property of accepting child nodes during parse time?
If you want to enhance the existing macro functionality to support a body, that would be a challenge. The existing #macro directive probably could not be used unless there was a way to specify the begin, body and end sections as in a JSP tag and then at runtime detect if the macro is a block or inline version.
Would you join me if I start developing this?
Don't have much time right now but I'll be happy to look at something you write.
Do you think it is possible?
Adding support for block macros would probably take a bit of effort and require patching the existing code.
Do you think it is simple to do?
Not really but I'm not an expert in the Velocity internals.
best regards, Dario.
PD: Perhaps a simpler startup is to have a simple directive that catches all its content and puts it in a string. Say:
#text into $mystr until '---end---' here code or anything ---end---
so with this simple directive I could perform a parse on runtime and even cache the internal representation in a hashTable according to filename and linenumber.
Yes, that would be lots simpler. It might look something like: #setinline($mystr) body text, etc. #end.
or maybe #collect would be a better name.
You can do something similar right now with a null parameter macro. But since you probably want to allow redefining this macro, you have to change one of the Velocity properties to allow it.
-Bill
Then it is just a matter of naming things or alike so to have this variable accesible from within any VM.
What do you think?
----- Original Message ----- From: "Bill Burton" <[EMAIL PROTECTED]> To: "Velocity Developers List" <[EMAIL PROTECTED]> Sent: Wednesday, February 26, 2003 14:45 Subject: Re: VM body node execution
Hello,
Dario Liberman wrote:
Hello,
I am new to velocity, I am from the near webmacro world. :-)
I was thinking about migrating to Velocity. And when I came to the VMs I found it interesting, but would like to increment its expressive power now that I got tempted to use it. The improvement goes subject to this question: I would like to have access inside a VM to the body node of the
macro's
callee, is it possible?
I am new to this, and I would like to accomplish it if it is possible.
Is
there any guru that can help me out?
Any comments are welcome.
Here I describe what uses I would be giving to it, with examples, so
that I
can explain myself.
for example:
code-> #macro( tostring $strvar ) #set ( $strvar = "$macro_body") ## this would do a kind of Velocity.execute($current_context, new stringwriter(req.get("$strvar")),macro_body_node) #end <-code
so when I use it: code-> #tostring ( $mystrvar) VM code here, with any statements, directives, etc. #end
The problem is macros can't have a body when being executed :( . It would be *really* nice if there were a way to do this. Right now, you would have to write a directive in order access the body.
-Bill
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
