Hi again!
Michael Dykman wrote:
On Tue, 2004-11-02 at 05:27, Christoph Reck wrote:
Hi,[snip]I would suggest to have inline pragma directives or something like the velocity-tools ToolboxManager to fine tune the scope of the settings (and allow third-party-macros and toolbox-templates to have their private settings?).
#pragma sounds like a lovely idea!! I wish I thought of that myself.
cool!
It will be a bit hard to keep Veracity in sync with Velocity, since some features like maps and multi-line directives are coming soon.
time will tell. the structure of the actual code is pretty transparent and, for the most part, adding features has not been a big hassle.
my small hope is that your anouncement gives a small push to move on with velocity... There is a list of wanted features, but where no concesus was yet reached... Many people = many opinions, the originators see it as work-for-me, and expect you to scratch-your-own-itch. When there are workaround and the lead expresses no favour to one proposal, no one takes the initiative - since it might not find its way into the core.
Will-Glass has done a great job in the past with many patches. To my knowledge some still reside in Bugzilla.
Others have initiated contribution areas in the Wiki - for voting, discussions, and macro contributions.
I do not yet fully understand your "structured" whitespace handling scheme (the name is superb!). Specially the part around "block comments". How would you allow something like: ... <table> #call( $formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0") ) #foreach( $row in $table.rows ) <tr color="$rowcolor" > #call( $rowcolor.alternate() ) #foreach( $d in $row.data )<td>$d</td>#end </tr> #end </table> and have nicely formatted output with all data together but yet indented?
(note: I am kind-of newbie to this list, I haven't missed the #call directive have I? I have just search vtl-reference-guide.html and the change log.. don't see a thing.. neat idea though)
It is a simple macro to avoid any side effects of a method call (return value):
#macro( call $foo )#if( $foo )#**##end#end
The #**# in the if-body avoided a parser bug in velocity 1.2.
Initially I had #macro( call $foo )#set( $dummy = $foo)#end which polluted the context.
I think this _would_ give you what you want if I supported the #call directive.. ({eat-WS} marks the whitespace that would disappear with structured WS handling)
<table> {eat-WS}#call( $formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0") ){eat-WS} {eat-WS}#foreach( $row in $table.rows ){eat-WS} <tr color="$rowcolor" > {eat-WS}#call( $rowcolor.alternate() ){eat-WS} {eat-WS}#foreach( $d in $row.data ){eat-WS} <td>$d</td>
nope :I here the data would appeach each on its own line. This is just an example test-case. How do I get all row data in one line? One solution is:
{eat-WS}#foreach( $d in $row.data ){eat-WS} {eat-WS-indent}#text( <td>$d</td> ){eat-WS} {eat-WS}#end{eat-WS}
where the #text is a simple macro. -> this would be a feasible solution with your structured whitepsace handling solution.
Another example is: #foreach( $d in $row.data ) $d#if( $velocityCount < $row.size() ),#end #end should producte a vertical list of indented data, not gobbling the newline at the end. How would your structured handling perform here?
{eat-WS}#end{eat-WS} </tr> {eat-WS}#end{eat-WS} </table>
The rest seems perfectly appropiate!
Still possible to do this using conventional factory methods and old-style method invocation.
#local($rowcolor = $factory.makeAlternator("#c0c0c0", "#e0e0e0")) ... <tr color="$rowcolor.alternate()" > ...
Could you please explain the expected behaviour of
$formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0")
to me? Is '$formatter' a special factory with access to the runtime variable space? I have an idea coming on...
I took the existing VelocityFormatter as an example: http://cvs.apache.org/viewcvs.cgi/jakarta-velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java?rev=HEAD
Your proposed pattern: #local( $rowcolor = $formatter.makeAlternator("#c0c0c0", "#e0e0e0") ) is better and keeps the context clean if it was in a macro or parsed template (does it?).
Than you very much for the feedback.. expect some of these suggestions to be implemented sooner than later.
Cheers, Christoph
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]