diff --git a/src/tools/common/template.py b/src/tools/common/template.py index 0852563f..12b1a99b 100644 --- a/src/tools/common/template.py +++ b/src/tools/common/template.py @@ -155,17 +155,20 @@ class ScriptsHandler(object): self.scripts = [] # we don't use a set because order may be important dummy, self.theme, self.is_default_theme = renderer.getThemeData(template_path) - def include(self, library_name): + def include(self, library_name, attribute='defer'): """Mark that a script need to be imported. Must be used before base.html is extended, as ' - for library in self.scripts: + tpl = u'' + for library, attribute in self.scripts: path = self.renderer.getStaticPath(library, self.template_root_dir, self.theme, self.is_default_theme, '.js') if path is None: log.warning(_(u"Can't find {}.js javascript library").format(library)) continue path = os.path.join(self.root_path, path) - scripts.append(tpl.format(src=quoteattr(path))) + scripts.append(tpl.format( + src = quoteattr(path), + attribute = attribute, + )) return safe(u'\n'.join(scripts))