Embedding an ejs template inside of an erb template

后端 未结 3 1438
天涯浪人
天涯浪人 2021-02-10 06:48

I\'m building a javascript-heavy rails 3 app. It uses underscore.js, which has a very elegant templating mechanism built on top of ejs ( http://embeddedjs.com/).

The pr

3条回答
  •  你的背包
    2021-02-10 07:32

    You could save ejs as a seperate file and than render it as a text (which won't be evaluated as erb) inside script tag.

    Inside your erb partial:

    `
    

    In your JavaScript file:

    new EJS({element: document.getElementById('my_awesome_template')}).render(data)
    

提交回复
热议问题