如何在javascript下划线模板中转义<>?

pay*_*ike 6 html javascript templates escaping pug

当使用下划线模板时,我想在anchor的href属性中插入一个值,如

a(href= "<%= id %>", class='products') //underscore template in jade
Run Code Online (Sandbox Code Playgroud)

但是输出是

<a href="&lt;% id %&gt;" class="products"> 
Run Code Online (Sandbox Code Playgroud)

那么如何转义<和>符号,并正确插值?

mtg*_*red 3

使用 != 而不是 = 来取消转义。

在你的情况下:

a.products(href!="<%= id %>")
Run Code Online (Sandbox Code Playgroud)