@@ -78,10 +78,11 @@ var entityRE = /&\w+;|&#\d+;|&#x[\dA-F]+;/
7878 * strategy found in jQuery & component/domify.
7979 *
8080 * @param {String } templateString
81+ * @param {Boolean } raw
8182 * @return {DocumentFragment }
8283 */
8384
84- function stringToFragment ( templateString ) {
85+ function stringToFragment ( templateString , raw ) {
8586 // try a cache hit first
8687 var hit = templateCache . get ( templateString )
8788 if ( hit ) {
@@ -106,7 +107,10 @@ function stringToFragment (templateString) {
106107 var suffix = wrap [ 2 ]
107108 var node = document . createElement ( 'div' )
108109
109- node . innerHTML = prefix + templateString . trim ( ) + suffix
110+ if ( ! raw ) {
111+ templateString = templateString . trim ( )
112+ }
113+ node . innerHTML = prefix + templateString + suffix
110114 while ( depth -- ) {
111115 node = node . lastChild
112116 }
@@ -238,17 +242,19 @@ exports.clone = function (node) {
238242 * instance template.
239243 *
240244 * @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>'
246250 * @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.
248254 * @return {DocumentFragment|undefined }
249255 */
250256
251- exports . parse = function ( template , clone , noSelector ) {
257+ exports . parse = function ( template , clone , raw ) {
252258 var node , frag
253259
254260 // if the template is already a document fragment,
@@ -262,7 +268,7 @@ exports.parse = function (template, clone, noSelector) {
262268
263269 if ( typeof template === 'string' ) {
264270 // id selector
265- if ( ! noSelector && template . charAt ( 0 ) === '#' ) {
271+ if ( ! raw && template . charAt ( 0 ) === '#' ) {
266272 // id selector can be cached too
267273 frag = idSelectorCache . get ( template )
268274 if ( ! frag ) {
@@ -275,7 +281,7 @@ exports.parse = function (template, clone, noSelector) {
275281 }
276282 } else {
277283 // normal string template
278- frag = stringToFragment ( template )
284+ frag = stringToFragment ( template , raw )
279285 }
280286 } else if ( template . nodeType ) {
281287 // a direct node
0 commit comments