Underscore.js Templates Within JSP

前端 未结 5 972
遥遥无期
遥遥无期 2020-12-13 10:08

Underscore.js templates use <%= %> for variable interpolation. Unfortunately that is also interpreted in a JSP (or GSP). Is there a way to use Underscore.js templates wit

5条回答
  •  没有蜡笔的小新
    2020-12-13 10:46

    Another option that doesn't require global replace is to specify the interpolate and evaluate to specific method invocation

     _.template($("#template-id").html(),null, {
       interpolate :  /\{\{\=(.+?)\}\}/g,
       evaluate: /\{\{(.+?)\}\}/g
     });`
    

提交回复
热议问题