Skip to content

Commit

Permalink
Merge a7a31ee into d7ab4b5
Browse files Browse the repository at this point in the history
  • Loading branch information
peuter committed Mar 14, 2019
2 parents d7ab4b5 + a7a31ee commit f5a2d3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion source/class/cv/parser/MetaParser.js
Expand Up @@ -371,10 +371,11 @@ qx.Class.define("cv.parser.MetaParser", {
}, this);
areq.send();
} else {
var cleaned = qx.bom.element.Attribute.get(elem, 'html').replace(/\n\s*/g, '').trim();
cv.parser.WidgetParser.addTemplate(
templateName,
// templates can only have one single root element, so we wrap it here
'<root>' + qx.bom.element.Attribute.get(elem, 'html') + '</root>'
'<root>' + cleaned + '</root>'
);
}
}, this);
Expand Down
10 changes: 5 additions & 5 deletions source/class/cv/parser/WidgetParser.js
Expand Up @@ -59,11 +59,11 @@ qx.Class.define('cv.parser.WidgetParser', {
}, this);

if (this.__templates.hasOwnProperty(templateName)) {
var renderedString = qx.bom.Template.render(this.__templates[templateName], variables).replace('\n', '').trim();
var div = document.createElement('div');
qx.bom.element.Attribute.set(div, 'html', renderedString.substring(6, renderedString.length - 7).trim());
// replace existing element with the rendered template (without <root> </root>)
elem.parentNode.replaceChild(div.firstChild, elem);
var renderedString = qx.bom.Template.render(this.__templates[templateName], variables);
var helperNode = elem.ownerDocument.createElement('div');
qx.bom.element.Attribute.set(helperNode, 'html', renderedString.substring(6, renderedString.length - 7));
// replace existing element with the rendered templates child
elem.parentNode.replaceChild(helperNode.firstChild, elem);
}
}, this);
},
Expand Down

0 comments on commit f5a2d3c

Please sign in to comment.