如何逃避<>在javascript下划线模板? [英] how to escape <> in javascript underscore template?

查看:110
本文介绍了如何逃避<>在javascript下划线模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  a(href =<% = id%>,class ='products')//下划线模板中的jade 

输出是

 < a href =& lt;%id%& gt类= 产品 > 

所以如何逃避<和/或>符号,并且正确插值?

解决方案

使用!=而不是=取消显示。
$ 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 %>")

这篇关于如何逃避&lt;&gt;在javascript下划线模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆