From 0cc140c52c82e3dfcf07a75213ec656116320d90 Mon Sep 17 00:00:00 2001 From: wittemann Date: Mon, 24 Oct 2011 11:29:19 +0200 Subject: [PATCH] Modified the get method to support more than one element in the template stored in the dom. --- mustache-qooxdoo/qooxdoo.mustache.js.tpl.pre | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mustache-qooxdoo/qooxdoo.mustache.js.tpl.pre b/mustache-qooxdoo/qooxdoo.mustache.js.tpl.pre index a70d0a4..42b3767 100644 --- a/mustache-qooxdoo/qooxdoo.mustache.js.tpl.pre +++ b/mustache-qooxdoo/qooxdoo.mustache.js.tpl.pre @@ -105,15 +105,29 @@ qx.Class.define("qx.bom.Template", { * @return {DomNode} A DOM element holding the parsed template data. */ get : function(id, view, partials) { + // get the content stored in the DOM var template = document.getElementById(id); var inner = template.innerHTML; - + + // apply the view inner = this.toHtml(inner, view, partials); - + + // special case for text only conversion + if (inner.search(/<|>/) === -1) { + return inner; + } + + // create a helper to convert the string into DOM nodes var helper = qx.bom.Element.create("div"); helper.innerHTML = inner; - return helper.children[0]; + // 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; } } });