Underscore.js Templates Within JSP

前端 未结 5 971
遥遥无期
遥遥无期 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:54

    Add the following interpolate and evaluate settings in your jsp page

    _.templateSettings = {
        interpolate: /\<\@\=(.+?)\@\>/gim,
        evaluate: /\<\@(.+?)\@\>/gim,
        escape: /\<\@\-(.+?)\@\>/gim
    };
    

    then you can write your qualify underscore variables,if and for statements with <@ @> instead of <% %> and will not conflict with jsp

提交回复
热议问题