You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2008/12/30 19:27:44 UTC

[jira] Updated: (VELOCITY-661) Parsing errors on content inside #literal() #end block

     [ https://issues.apache.org/jira/browse/VELOCITY-661?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna updated VELOCITY-661:
----------------------------------

    Issue Type: Improvement  (was: Bug)

#literal wasn't designed with that in mind.  The parser only knows that #literal is a directive, not that it should treat it specially.  Still, while not a bug, this would be a better way for #literal to work.

Typical practice for your situation is to either "poor man's escaping":

#set( $D = '$' )
#set( $H = '#' )## or use EscapeTool:  $esc.h  and $esc.d
var myId = 'someId';
$D('${H}test').append(${D}.template('<div id="$D{myId}"></div>').apply({myId: myId}));

or to put long sections into a separate file and use #include( 'myscript.txt' ) to bring it back into the template.  #include most definitely does not parse the files it brings in.

> 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org