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

Nathan Bubna commented on VELOCITY-661:
---------------------------------------

Well, "interpret" is apparently not the clearest of terms, and the docs could 
use some improvement (no surprise there).   Still, nothing within a #literal 
directive is interpreted, in the sense that it is rendered literally, as the 
examples show.  However, #literal is not a special directive in any sense.  The 
parser hasn't a clue what #literal intends to do with its content.  So, 
everything within a #literal block is still parsed.

Like i said, #literal was never designed to prevent parsing of content.  
#literal was to make it easy to escape large sections of valid VTL.  like most 
escaping issues people have with Velocity, they expect to escape invalid VTL, 
but all of Velocity's escaping mechanisms (#literal included) were designed to 
escape valid VTL only.  This is something i think everyone is ready to change 
in 2.0, but that doesn't mean it wasn't intentional when it was first done (not 
by me, i might add :).

So, to change the #literal directive to make the parser be lenient about its 
content, you will have to hardwire knowledge about it into the parser itself.  
I'm willing to help commit and test such a solution, but i really don't have 
time to develop it myself.

> Parsing errors on content inside #literal() #end block
> ------------------------------------------------------
>
>                 Key: VELOCITY-661
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-661
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.1
>         Environment: ALL
>            Reporter: ND
>
> I have some velocity templates that include quit some javascript. Inside the 
> javascript a javascrip template engine is used which also uses ${varname}
> Escaping each occurance would make the code rather unreable, so to prevent 
> velocity from parsing the javascript code, I put a #literal() around it.
> However, velocity still PARSES the contents of this block, which of course 
> results in parsing exceptions.
> My feeling with "literal" is that it is completely UNINTERPRETED content?
> This SHOULD work:
> #literal()
>  var myId = 'someID';
>  $('#test).append($.template('<div id="${myId}"></div>').apply({myId: myId}));
> #end

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to