You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Will Glass-Husain <wg...@forio.com> on 2007/01/03 15:23:51 UTC
Re: #evaluate
[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, apache@recks.org <ap...@recks.org> 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: dev-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: dev-help@velocity.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: #evaluate
Posted by Will Glass-Husain <wg...@forio.com>.
That makes sense. Maps, anything implementing get/put, and Context objects.
WILL
On 1/3/07, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>
> On Jan 3, 2007, at 9:23 AM, Will Glass-Husain 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.
>
> So would having a syntactical device to do it...
>
> >
> > Another idea is to have an optional argument with a map that would
> > serve as a context.
> >
> > #evaluate("hello from $name",{"name":"Will"})
>
> Well, you'd probably want it to be anything appropriate, including a
> Context :)
>
> >
> > WILL
> >
> > On 1/3/07, apache@recks.org <ap...@recks.org> 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: dev-unsubscribe@velocity.apache.org
> >> >> For additional commands, e-mail: dev-help@velocity.apache.org
> >> >>
> >> >
> >> >
> >> >
> >> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> >> > For additional commands, e-mail: dev-help@velocity.apache.org
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: dev-help@velocity.apache.org
> >>
> >>
> >
> >
> > --
> > Forio Business Simulations
> >
> > Will Glass-Husain
> > wglass@forio.com
> > www.forio.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: #evaluate
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Jan 3, 2007, at 9:23 AM, Will Glass-Husain 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.
So would having a syntactical device to do it...
>
> Another idea is to have an optional argument with a map that would
> serve as a context.
>
> #evaluate("hello from $name",{"name":"Will"})
Well, you'd probably want it to be anything appropriate, including a
Context :)
>
> WILL
>
> On 1/3/07, apache@recks.org <ap...@recks.org> 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: dev-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: dev-help@velocity.apache.org
>> >>
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: dev-help@velocity.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: dev-help@velocity.apache.org
>>
>>
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> wglass@forio.com
> www.forio.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: #evaluate
Posted by Will Glass-Husain <wg...@forio.com>.
Good point. if we did this, keeping it simple (with the default
context) makes a lot of sense.
The #evaluate functionality seems simple enough, I'm enthused about
including it (eventually, anyway).
WILL
On 1/3/07, Nathan Bubna <nb...@gmail.com> wrote:
> 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 <wg...@forio.com> 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, apache@recks.org <ap...@recks.org> 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: dev-unsubscribe@velocity.apache.org
> > > >> For additional commands, e-mail: dev-help@velocity.apache.org
> > > >>
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: dev-help@velocity.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: dev-help@velocity.apache.org
> > >
> > >
> >
> >
> > --
> > Forio Business Simulations
> >
> > Will Glass-Husain
> > wglass@forio.com
> > www.forio.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: #evaluate
Posted by Nathan Bubna <nb...@gmail.com>.
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 <wg...@forio.com> 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, apache@recks.org <ap...@recks.org> 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: dev-unsubscribe@velocity.apache.org
> > >> For additional commands, e-mail: dev-help@velocity.apache.org
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: dev-help@velocity.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> wglass@forio.com
> www.forio.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org