template: added media_path to template data

This commit is contained in:
Goffi 2017-10-27 08:36:24 +02:00
commit 3c4dfb4636

View file

@ -377,13 +377,15 @@ class Renderer(object):
# jinja use string when no special char is used, so we have to convert to unicode
return unicode(template).format(value=value, **kwargs)
def render(self, template, theme=None, locale=DEFAULT_LOCALE, root_path=u'', css_files=None, css_inline=False, **kwargs):
def render(self, template, theme=None, locale=DEFAULT_LOCALE, root_path=u'', media_path=u'', css_files=None, css_inline=False, **kwargs):
"""render a template
@param template(unicode): template to render (e.g. blog/articles.html)
@param theme(unicode): template theme
@param root_path(unicode): prefix of the path/URL to use for template root
must end with a u'/'
@param media_path(unicode): prefix of the SàT media path/URL to use for template root
must end with a u'/'
@param css_files(list[unicode],None): CSS files to used
CSS files must be in static dir of the template
use None for automatic selection of CSS files based on template category
@ -424,4 +426,4 @@ class Renderer(object):
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=self._locale, gidx=Indexer(), script=scripts_handler, **kwargs)
return template_source.render(theme=theme, root_path=root_path, media_path=media_path, css_files=css_files, locale=self._locale, gidx=Indexer(), script=scripts_handler, **kwargs)