You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (JIRA)" <ji...@apache.org> on 2018/10/15 09:33:00 UTC

[jira] [Commented] (VELOCITY-876) Support a Configurable EL within ${{...}} also $!{{...}} tags

    [ https://issues.apache.org/jira/browse/VELOCITY-876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649969#comment-16649969 ] 

Claude Brisson commented on VELOCITY-876:
-----------------------------------------

I took a closer look at JEXP. And I'm having some doubts about the pertinence of the feature.

Templating is not scripting and do not pursue the same goals. The spirit of templating is to separate business logic from presentation, by providing a simple language for the view layer. Scripting languages like JEXP are firstly meant to provide an accessible and convenient way to model business logic.

Allowing ${\{  }} and #if( ${\{  }} ) inside Velocity templates doesn't seem to be very orthodox from that perspective.

To my mind, the most natural link between JEXP and Velocity would be the other way around: to let JEXP users merge Velocity templates (and that doesn't look so hard). I even wonder why JEXP did provide its own string interpolation mechanism instead of relying on Velocity, by the way.

 

> Support a Configurable EL within ${{...}} also $!{{...}} tags
> -------------------------------------------------------------
>
>                 Key: VELOCITY-876
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-876
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.7
>            Reporter: Terefang Verigorn
>            Priority: Minor
>             Fix For: 2.1.x
>
>
> Since Velocity2 is a Major version, why not start to support some new features?
> As of Velocity 1.x you can use ${ name } to refer to object "name" in the context, or use $!{ name } if you want "" for null values.
> How about using ${{ el-expression }} to evaluate and output the given "el-expression" in a configured el-engine with the current velocity context, same should hold for $!{{ el-expression }}.
> Some possible engines would be :
> commons-el, commons-jexl, ognl, mvel
> if using el/jexl ${{ name }} would be mostly the same as ${ name }.
> usage cases:
> the simple ${{ ... }} would allow more complicated expressions than present in the plain engine, especially if we look at the jexl2/3 features
> #if( ${{ ... }} ) -- would improve the boolean issue because the el could be used to wrap in "a?x:y"
> architecture:
> thru api abstraction, almost any el could be plugged in ( even groovy.eval or jsr223 )
> core engine could ship with the api and el or jexl as the reference impl, other bindings would be optional jars with thier own deps.
> brain storming:
> how about supporting non-outputting el/jsr223 between #{{ ... #}} tags, like:
> ------
> #{{ /* jexl code */
> var = [ 1,2,3,4,5,6,7 ];
> #}}
> #foreach( $n in $var )
> $n
> #end
> ------



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org