Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unescape '&' in Jade

Tags:

pug

Finding some difficulty rendering out '&' using the Jade engine. I need to make a call to Google Maps using the following string: script(type='text/javascript', src='http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE')

But this will be rendered in Jade as: src="http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE

like image 241
ngzhongcai Avatar asked Feb 20 '12 15:02

ngzhongcai


People also ask

How do you unescape in HTML?

One way to unescape HTML entities is to put our escaped text in a text area. This will unescape the text, so we can return the unescaped text afterward by getting the text from the text area. We have an htmlDecode function that takes an input string as a parameter.

How do you decode Unescape?

In JavaScript, to decode a string unescape() method is used. This method takes a string, which is encoded by escape() method, and decodes it. The hexadecimal characters in a string will be replaced by the actual characters they represent using unescape() method.

What is unescape function?

unescape() Programmers should not use or assume the existence of these features and behaviors when writing new ECMAScript code. … The unescape() function computes a new string in which hexadecimal escape sequences are replaced with the character that it represents.

What is unescape () and escape () functions?

1. The unescape() function is used to decode that string encoded by the escape() function. The escape() function in JavaScript is used for encoding a string. Using ASCII character support, it makes a string portable so that it can be transmitted across any network to any computer.


1 Answers

Still according to https://github.com/visionmedia/jade/issues/198 it is now possible to write:

script(type='text/javascript', src!='http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE')

Note the != for the src argument; thus its content is not escaped.

like image 117
Jean Avatar answered Oct 17 '22 19:10

Jean