mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] qweb: allow xml documents as template definition
Before this commit, the addTemplates method only accepts a string. But whenever we perform a $.get call, we get a parsed xml document. So, to make Owl more convenient to use in that situation, we simply accept xml documents in addition to strings.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "owl",
|
"name": "owl",
|
||||||
"version": "0.18.0",
|
"version": "0.18.1",
|
||||||
"description": "Odoo Web Library (OWL)",
|
"description": "Odoo Web Library (OWL)",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+5
-5
@@ -207,12 +207,12 @@ export class QWeb extends EventBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load templates from a xml (as a string). This will look up for the first
|
* Load templates from a xml (as a string or xml document). This will look up
|
||||||
* <templates> tag, and will consider each child of this as a template, with
|
* for the first <templates> tag, and will consider each child of this as a
|
||||||
* the name given by the t-name attribute.
|
* template, with the name given by the t-name attribute.
|
||||||
*/
|
*/
|
||||||
addTemplates(xmlstr: string) {
|
addTemplates(xmlstr: string | Document) {
|
||||||
const doc = parseXML(xmlstr);
|
const doc = typeof xmlstr === 'string' ? parseXML(xmlstr) : xmlstr;
|
||||||
const templates = doc.getElementsByTagName("templates")[0];
|
const templates = doc.getElementsByTagName("templates")[0];
|
||||||
if (!templates) {
|
if (!templates) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user