Skip to content

Commit

Permalink
fix template rendering (needs to be tested in safari/ios).
Browse files Browse the repository at this point in the history
  • Loading branch information
peuter authored and ChristianMayer committed Mar 24, 2019
1 parent 8655428 commit cd91fc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion source/class/cv/parser/MetaParser.js
Expand Up @@ -363,10 +363,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
8 changes: 4 additions & 4 deletions source/class/cv/parser/WidgetParser.js
Expand Up @@ -60,10 +60,10 @@ qx.Class.define('cv.parser.WidgetParser', {

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 helperNode = elem.ownerDocument.createElement('template');
qx.bom.element.Attribute.set(helperNode, 'html', renderedString.substring(6, renderedString.length - 7).trim());
// replace existing element with the rendered templates child
elem.parentNode.replaceChild(helperNode.firstElementChild, elem);
}
}, this);
},
Expand Down

0 comments on commit cd91fc4

Please sign in to comment.