| @@ -97,7 +97,8 @@ qx.Class.define("qx.bom.Template", { | |||||
| * Helper method which provides you with a direct access to templates | * Helper method which provides you with a direct access to templates | ||||
| * stored as HTML in the DOM. The DOM node with the given ID will be reated | * stored as HTML in the DOM. The DOM node with the given ID will be reated | ||||
| * as a template, parsed and a new DOM node will be returned containing the | * as a template, parsed and a new DOM node will be returned containing the | ||||
| * parsed data. | |||||
| * parsed data. Keep in mind to have only one root DOM element in the the | |||||
| * template. | |||||
| * | * | ||||
| * @param id {String} The id of the HTML template in the DOM. | * @param id {String} The id of the HTML template in the DOM. | ||||
| * @param view {Object} The object holding the data to render. | * @param view {Object} The object holding the data to render. | ||||
| @@ -108,26 +109,20 @@ qx.Class.define("qx.bom.Template", { | |||||
| // get the content stored in the DOM | // get the content stored in the DOM | ||||
| var template = document.getElementById(id); | var template = document.getElementById(id); | ||||
| var inner = template.innerHTML; | var inner = template.innerHTML; | ||||
| // apply the view | // apply the view | ||||
| inner = this.toHtml(inner, view, partials); | inner = this.toHtml(inner, view, partials); | ||||
| // special case for text only conversion | // special case for text only conversion | ||||
| if (inner.search(/<|>/) === -1) { | if (inner.search(/<|>/) === -1) { | ||||
| return inner; | return inner; | ||||
| } | } | ||||
| // create a helper to convert the string into DOM nodes | // create a helper to convert the string into DOM nodes | ||||
| var helper = qx.bom.Element.create("div"); | var helper = qx.bom.Element.create("div"); | ||||
| helper.innerHTML = inner; | helper.innerHTML = inner; | ||||
| // use a document fragment to return more than one note | |||||
| var docFragment = document.createDocumentFragment(); | |||||
| for (var i = helper.childNodes.length - 1; i >= 0; i--) { | |||||
| qx.dom.Element.insertBegin(helper.childNodes[i], docFragment); | |||||
| }; | |||||
| return docFragment; | |||||
| return helper.children[0]; | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||