how to escape <> in javascript underscore template?

十年热恋 提交于 2019-12-13 06:03:20

问题


when using underscore template i want to interpolate a value in anchor's href attribute like

a(href= "<%= id %>", class='products') //underscore template in jade

but the out put is

<a href="&lt;% id %&gt;" class="products"> 

so how to escape the < and > sign , and interpolate the value correctly?


回答1:


Use != instead of = to unescape.

In your case:

a.products(href!="<%= id %>")


来源:https://stackoverflow.com/questions/12351148/my-underscore-template-is-not-working-in-jade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!