The more canonical example for an "evaluate" tool (or directive) is
being ably to dynamically decide what method to call on a particular
reference. So, something along the lines of:
#if( $this > $that )
#set( $method = $foo )
#else
#set( $method = $bar )
#end
$render.eval( "\${someRef}.${method}" )
Though, Christoph's example gets to the same point quicker.
While i am quite fine with providing a tool or a directive for
advanced users to do this, i really don't think it's practical,
necessary, or wise to bend over backwards to support this sort of
thing. So, i'm not even sure i'm ready to automatically include such
a directive in the default directive.properties, much less add some
new-fangled syntax for doing such things. At least an #evaluate
directive wouldn't really be growing the VTL language.
And as far as adding on optional parameter to narrow the context for
such evaluations, i think i can say with great confidence that YAGNI.
I don't think most people even need #evaluate, much less one with
such fine-grained context control.
On 1/3/07, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
[I'm changing the subject line-- I kept looking for this discussion in JIRA]
Great way of way of framing this, Christopher. Thinking about
#evaluate as a companion to #include and #parse makes me realize this
new proposed directive fits within the Velocity approach.
Another idea is to have an optional argument with a map that would
serve as a context.
#evaluate("hello from $name",{"name":"Will"})
WILL
On 1/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> No, the #evaluate directive is to be used as it the following example:
>
> #set( $error = $i18n_tool.getMessage("ERROR123") )
> #evaluate( $error )## reder by merging with context
>
> It something like the #parse directive, but the content comes
> from a string and not a file.
>
> :) Christoph
>
> Geir Magnusson Jr. wrote:
> > Do you mean
> >
> > $foo = "#foreach($a in $b) ...... #end"
> >
> > ?
> >
> > If so, why not just do it that way, rather than add a new directive?
> >
> > geir
> >
> >
> > On Jan 2, 2007, at 11:47 PM, Will Glass-Husain (JIRA) wrote:
> >
> >> Add new directive #evaluate
> >> ---------------------------
> >>
> >> Key: VELOCITY-509
> >> URL: https://issues.apache.org/jira/browse/VELOCITY-509
> >> Project: Velocity
> >> Issue Type: New Feature
> >> Components: Engine
> >> Affects Versions: 1.5 beta2
> >> Reporter: Will Glass-Husain
> >> Priority: Minor
> >> Fix For: 1.6
> >>
> >>
> >> On a separate issue (VELOCITY-504) we came up with the idea of a new
> >> directive, #evaluate. Basically, it would act just like
> >> Velocity.evaluate().
> >>
> >> Users are always asking for this capability (internal evaluation).
> >> Usually we tell them to "use a tool". Instead, we should just put in
> >> a simple directive that would evaluate a VTL string using the current
> >> context.
> >>
> >> Incidentally, this should be the current local context, e.g. if inside
> >> a macro or a foreach loop (or worse, both) it should use that
> >> context. See VELOCITY-504 for why this is needed.
> >>
> >> --This message is automatically generated by JIRA.
> >> -
> >> If you think it was sent incorrectly contact one of the
> >> administrators: https://issues.apache.org/jira/secure/Administrators.jspa
> >> -
> >> For more information on JIRA, see: http://www.atlassian.com/software/jira
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Forio Business Simulations
Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]