mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] app: allow to instantiate templates lazily
With this commit, the templates that are given while instantiating the App class can be an object with templates not yet parsed (i.e. string, not Document). This allow to instantiate the App class with templates that are not yet parsed, and these templates will be parsed only when needed. Part of task-id 3601257
This commit is contained in:
committed by
Sam Degueldre
parent
a53e42518f
commit
941190dfa8
@@ -41,7 +41,7 @@ export interface TemplateSetConfig {
|
||||
dev?: boolean;
|
||||
translatableAttributes?: string[];
|
||||
translateFn?: (s: string) => string;
|
||||
templates?: string | Document;
|
||||
templates?: string | Document | Record<string, string>;
|
||||
}
|
||||
|
||||
export class TemplateSet {
|
||||
@@ -60,7 +60,13 @@ export class TemplateSet {
|
||||
this.translateFn = config.translateFn;
|
||||
this.translatableAttributes = config.translatableAttributes;
|
||||
if (config.templates) {
|
||||
this.addTemplates(config.templates);
|
||||
if (config.templates instanceof Document || typeof config.templates === "string") {
|
||||
this.addTemplates(config.templates);
|
||||
} else {
|
||||
for (const name in config.templates) {
|
||||
this.addTemplate(name, config.templates[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user