Little optimitation in mako templates wrapper
This commit is contained in:
parent
b01dbb7053
commit
20cc7dff36
1 changed files with 18 additions and 12 deletions
|
|
@ -35,7 +35,11 @@ class ptemplate:
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
|
|
||||||
module=path.dirname(module)
|
ext=module[len(module)-3:]
|
||||||
|
|
||||||
|
if ext=='.py':
|
||||||
|
|
||||||
|
module=path.dirname(module)
|
||||||
|
|
||||||
self.autoescape_ext=('html', 'htm', 'xml', 'phtml')
|
self.autoescape_ext=('html', 'htm', 'xml', 'phtml')
|
||||||
|
|
||||||
|
|
@ -66,6 +70,10 @@ class ptemplate:
|
||||||
|
|
||||||
self.add_filter(add_header_home)
|
self.add_filter(add_header_home)
|
||||||
|
|
||||||
|
self.filters['HeaderHTML']=HeaderHTML
|
||||||
|
|
||||||
|
self.filters['show_flash_message']=show_flash_message
|
||||||
|
|
||||||
#self.auto_reload=True
|
#self.auto_reload=True
|
||||||
|
|
||||||
# Clean HeaderHTML
|
# Clean HeaderHTML
|
||||||
|
|
@ -76,7 +84,8 @@ class ptemplate:
|
||||||
HeaderHTML.cache_header=[]
|
HeaderHTML.cache_header=[]
|
||||||
HeaderHTML.css_local={}
|
HeaderHTML.css_local={}
|
||||||
HeaderHTML.js_local={}
|
HeaderHTML.js_local={}
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_header_cache():
|
def clean_header_cache():
|
||||||
|
|
||||||
|
|
@ -97,13 +106,13 @@ class ptemplate:
|
||||||
|
|
||||||
def env_theme(self, module):
|
def env_theme(self, module):
|
||||||
|
|
||||||
theme_templates='themes/'+config.theme+'/templates'
|
standard_templates=path.dirname(__file__)+'/templates'
|
||||||
|
|
||||||
module_templates=module+'/templates'
|
module_templates=module+'/templates'
|
||||||
|
|
||||||
#Standard templates
|
theme_templates='themes/'+config.theme+'/templates'
|
||||||
|
|
||||||
standard_templates=path.dirname(__file__)+'/templates'
|
#Standard templates
|
||||||
#print(standard_templates)
|
#print(standard_templates)
|
||||||
return TemplateLookup(directories=[theme_templates, module_templates, standard_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace')
|
return TemplateLookup(directories=[theme_templates, module_templates, standard_templates], default_filters=['h'], input_encoding='utf-8', encoding_errors='replace')
|
||||||
|
|
||||||
|
|
@ -113,15 +122,12 @@ class ptemplate:
|
||||||
|
|
||||||
template = self.env.get_template(template_file)
|
template = self.env.get_template(template_file)
|
||||||
|
|
||||||
arguments['HeaderHTML']=HeaderHTML
|
|
||||||
|
|
||||||
arguments['show_flash_message']=show_flash_message
|
|
||||||
|
|
||||||
for filter_name, filter_ in self.filters.items():
|
|
||||||
arguments[filter_name]=filter_
|
|
||||||
|
|
||||||
#Will be nice add hooks here
|
#Will be nice add hooks here
|
||||||
|
|
||||||
|
#z = x.copy()
|
||||||
|
|
||||||
|
arguments.update(self.filters)
|
||||||
|
|
||||||
return template.render(**arguments)
|
return template.render(**arguments)
|
||||||
|
|
||||||
def add_filter(self, filter_name):
|
def add_filter(self, filter_name):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue