Using Jade templates in Backbone.js

后端 未结 5 741
南旧
南旧 2020-12-24 07:07

I love the HAML-like syntax of Jade\'s templating engine in Node.js, and I would love to use it client-side within Backbone.js.

I\'ve seen Backbone commonly using Un

5条回答
  •  难免孤独
    2020-12-24 07:38

    You won't get the full power of Jade templates, but you can hack it a bit to get jade to properly output underscore templates, the key is preventing jade from escaping the <%> tags with the ! operator, like so:

    script#dieTemplate(type='text/template')
        .die(class!='value-<%= value %>')
            i.fa.fa-circle
            i.fa.fa-circle
            i.fa.fa-circle
            i.fa.fa-circle
            i.fa.fa-circle
            i.fa.fa-circle
            i.fa.fa-star
    

提交回复
热议问题