velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rene Parra <>
Subject Re: Velocimacro argument (by-name) passing
Date Mon, 19 Jul 2004 18:38:57 GMT
This is primarily resulting from a need to "componentize" my UI.
There are several pages that re-use the same structure, but vary in content.
I might have #content1() on one page, and #content2() on the other, but they might all share
the same structure.  Also, the #content() may need page-supplied, variations that are not
common across all features.  For example I might have something like the following:
<form ...>
  #renderTable("#myHeader()" "#myRow($row)")
Note that in this example #myRow() takes an argument that only makes sense
within the macro #renderTable.
I agree that this is a little complex for templates, but this sort of thing would look very
simple in JSP Tags:
<mytlib:form ...>
  <mytlib:table  rowvar="row">

Nathan Bubna <> wrote:

> The only solution that I have found is to create a macro for each "deferred
> For example:
> #macro (bolddiv1)
> #bold( "$innerVar hello - 1st div")
> #end
> #macro (bolddiv2)
> #bold( "$innerVar hello - 2st div")
> #end
> #reusableStruct( "#bolddiv1()" "#bolddiv2()")
> This gives me the most readability without sacrificing flexibility in
> terms of argument-evaluation deferrment.
> Any drawbacks to this approach?

hmm. i dunno, i haven't done this sort of thing (at least not to this
degree). a bit too complex for my tastes. my only suggestion would be to pay
attention to your configuration w.r.t. velocimacros
(libraries, overridability, global/local, etc.) to avoid needless

Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message