且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何逃避<>在javascript下划线模板?

更新时间:2022-10-21 19:32:04

使用!=而不是=取消显示。
$ b

在你的情况下:

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


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?

Use != instead of = to unescape.

In your case:

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