Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to escape <> in javascript underscore template?

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?

like image 599
paynestrike Avatar asked Sep 11 '12 03:09

paynestrike


1 Answers

Use != instead of = to unescape.

In your case:

a.products(href!="<%= id %>")
like image 152
mtgred Avatar answered Oct 25 '22 20:10

mtgred