Rails with Underscore.js Templates

后端 未结 2 785
别跟我提以往
别跟我提以往 2021-01-31 09:59

I was trying to use underscore.js templates for templating in a rails 2.3 app which does not have jammit as an asset packager.

Here is the simple Templa

2条回答
  •  梦谈多话
    2021-01-31 10:48

    Use some other delimiters instead of <%= %>. For example, to use mustache-style brackets {{= }} (interpolate) and {{ }} (evaluate), add this somewhere to your javascript:

    _.templateSettings = {
        interpolate: /\{\{\=(.+?)\}\}/g,
        evaluate: /\{\{(.+?)\}\}/g
    };
    

提交回复
热议问题