1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-25 23:06:55 +01:00

[#101] A default templates_base_directory can be set in the instance settings

This commit is contained in:
Roland Haroutiounian 2016-01-08 16:07:31 +01:00
commit 6161420eed
3 changed files with 7 additions and 2 deletions

View file

@ -19,4 +19,5 @@ MANDATORY = [
ALLOWED = [
'em_graph_output',
'em_graph_format',
'templates_base_dir'
]

View file

@ -21,12 +21,13 @@ class TemplateLoader(object):
# @param template_file str : path to the template file (starting from the base path used to instanciate the
# TemplateLoader)
# @param template_vars dict : parameters to be used in the template
# @param template_extra list : list of custom modules to import in the template (default value : None)
# @return str. String containing the HTML output of the processed templated
def render_to_html(self, template_file, template_vars={}, template_extra={}):
def render_to_html(self, template_file, template_vars={}, template_extra=None):
loader = jinja2.FileSystemLoader(searchpath=self.search_path, followlinks=self.follow_links)
environment = jinja2.Environment(loader=loader)
template = environment.get_template(template_file)
if template_extra is not None or template_extra != {}:
if template_extra is not None:
for extra in template_extra:
template.globals[extra[0]] = extra[1]
return template.render(template_vars)

View file

@ -1,10 +1,13 @@
#-*- coding:utf8 -*-
import pymysql
import os
sitename = 'LODEL2_INSTANCE_NAME'
lodel2_lib_path = 'LODEL2_LIB_ABS_PATH'
templates_base_dir = 'LODEL2_INSTANCE_TEMPLATES_BASE_DIR'
debug = False
em_file = 'em.json'