Inside of a Jade file, I have a JavaScript string like - var example = "Hello #[a(href='#') World]"
, which I pass to a paragraph element like p=example
.
This undesirably outputs an HTML paragraph element like <p>Hello #[a(href='#') World]</p>
.
The output I am looking for is <p>Hello <a href='#'>World</a></p>
Is there any trick around this? Am I going about this poorly?
Thanks in advance.
EDIT:
I just found this article in the Jade documents on escaping . Which gives a similar example (I edited it to match my example):
The updated JavaScript string is - var example = "Hello <a href='#'>World</a>"
p=example
=> <p>Hello <a href='#'>World</a></p>
p!=example
=> <p>Hello <a href='#'>World</a></p>
I'm going to test this out now.
EDIT2:
It works! Now to do a lot of editing...
Check http://codepen.io/anon/pen/wMdPdX
- var example = "Hello <a(href='#')>World<a/>" p!{example}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.