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

Christoph Reck commented on VELOCITY-661:
-----------------------------------------

To avoid to have to make to many changes to the parser, maybe the interface or 
semantics of directives can be enhanced with a feature to tell the parser to go 
into a "simple" mode where it skips parsing into AST until the end marker is 
reached.

It would be nice to be able to tell it what the end marker is, similar to the 
suggestion above (I changed it to contain the "#"):
  #literal('#litend')
  ...#end...
  #litend 

To leave a single limitation that requires avoiding an "#end" within the block 
is only partially acceptable.
  #set( $H = '#' )
  #literal()
  ...${H}end...
  #end
Custom directives that do their own magic with the block content would not know 
what to do with an embedded "${H}", which would require some 
pre-processing/rendering of the block before using it (interesting idea... 
would allow some dynamically velocity created content before directive 
activity). Alternatively, the custom directive could allow its own escaping 
syntax.


> 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