@@ -78,10 +78,11 @@ var entityRE = /&\w+;|&#\d+;|&#x[\dA-F]+;/
78
78
* strategy found in jQuery & component/domify.
79
79
*
80
80
* @param {String } templateString
81
+ * @param {Boolean } raw
81
82
* @return {DocumentFragment }
82
83
*/
83
84
84
- function stringToFragment ( templateString ) {
85
+ function stringToFragment ( templateString , raw ) {
85
86
// try a cache hit first
86
87
var hit = templateCache . get ( templateString )
87
88
if ( hit ) {
@@ -106,7 +107,10 @@ function stringToFragment (templateString) {
106
107
var suffix = wrap [ 2 ]
107
108
var node = document . createElement ( 'div' )
108
109
109
- node . innerHTML = prefix + templateString . trim ( ) + suffix
110
+ if ( ! raw ) {
111
+ templateString = templateString . trim ( )
112
+ }
113
+ node . innerHTML = prefix + templateString + suffix
110
114
while ( depth -- ) {
111
115
node = node . lastChild
112
116
}
@@ -238,17 +242,19 @@ exports.clone = function (node) {
238
242
* instance template.
239
243
*
240
244
* @param {* } template
241
- * Possible values include:
242
- * - DocumentFragment object
243
- * - Node object of type Template
244
- * - id selector: '#some-template-id'
245
- * - template string: '<div><span>{{msg}}</span></div>'
245
+ * Possible values include:
246
+ * - DocumentFragment object
247
+ * - Node object of type Template
248
+ * - id selector: '#some-template-id'
249
+ * - template string: '<div><span>{{msg}}</span></div>'
246
250
* @param {Boolean } clone
247
- * @param {Boolean } noSelector
251
+ * @param {Boolean } raw
252
+ * inline HTML interpolation. Do not check for id
253
+ * selector and keep whitespace in the string.
248
254
* @return {DocumentFragment|undefined }
249
255
*/
250
256
251
- exports . parse = function ( template , clone , noSelector ) {
257
+ exports . parse = function ( template , clone , raw ) {
252
258
var node , frag
253
259
254
260
// if the template is already a document fragment,
@@ -262,7 +268,7 @@ exports.parse = function (template, clone, noSelector) {
262
268
263
269
if ( typeof template === 'string' ) {
264
270
// id selector
265
- if ( ! noSelector && template . charAt ( 0 ) === '#' ) {
271
+ if ( ! raw && template . charAt ( 0 ) === '#' ) {
266
272
// id selector can be cached too
267
273
frag = idSelectorCache . get ( template )
268
274
if ( ! frag ) {
@@ -275,7 +281,7 @@ exports.parse = function (template, clone, noSelector) {
275
281
}
276
282
} else {
277
283
// normal string template
278
- frag = stringToFragment ( template )
284
+ frag = stringToFragment ( template , raw )
279
285
}
280
286
} else if ( template . nodeType ) {
281
287
// a direct node
0 commit comments