# HG changeset patch # User Goffi # Date 1498328335 -7200 # Node ID 3226945432255d00ba170664ca0aa117d53a8423 # Parent a8eaaac4d80fc3fade729f7084f447720f4fa57d tools (common/template): ScriptsHandler fix/improvments: ScriptsHandler was not used so far, this commit fix it to be usable: - script can be imported with "include" - generate_scripts is used to generate the ' - for library,data in self.scripts: + tpl = u'' + for library 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))) - return u'\n'.join(scripts) + return safe(u'\n'.join(scripts)) class Renderer(object): @@ -357,8 +366,8 @@ if css_contents: kwargs['css_content'] = '\n'.join(css_contents) - scripts_handler = ScriptsHandler(self, template_path, template_root_dir) + scripts_handler = ScriptsHandler(self, template_path, template_root_dir, root_path) self.setLocale(locale) # XXX: theme used in template arguments is the requested theme, which may differ from actual theme # if the template doesn't exist in the requested theme. - return template_source.render(theme=theme, root_path=root_path, css_files=css_files, locale=locale, gidx=Indexer(), scripts_handler=scripts_handler, **kwargs) + return template_source.render(theme=theme, root_path=root_path, css_files=css_files, locale=self._locale, gidx=Indexer(), script=scripts_handler, **kwargs)