Skip to content

Commit

Permalink
Get common template variables at class init
Browse files Browse the repository at this point in the history
  • Loading branch information
tankywoo committed Feb 8, 2016
1 parent 164fafb commit 1583f11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions simiki/generators.py
Expand Up @@ -42,6 +42,7 @@ def __init__(self, site_config, base_path):
self.site_config = copy.deepcopy(site_config)
self.base_path = base_path
self._templates = {} # templates cache
self._template_vars = self._get_template_vars()
_template_path = os.path.join(
self.base_path,
site_config["themes_dir"],
Expand Down Expand Up @@ -166,7 +167,7 @@ def get_layout(self, meta):

def get_template_vars(self, meta, content):
"""Get template variables, include site config and page config"""
template_vars = self._get_template_vars()
template_vars = copy.deepcopy(self._template_vars)
category, src_fname = self.get_category_and_file()
dst_fname = src_fname.replace(
".{0}".format(self.site_config["default_ext"]), ".html")
Expand Down Expand Up @@ -299,7 +300,7 @@ def _cmp(arg1, arg2):
return sorted_structure

def get_template_vars(self):
template_vars = self._get_template_vars()
template_vars = copy.deepcopy(self._template_vars)
structure = self.sort_structure(self.get_content_structure_and_meta())
template_vars['site'].update({'structure': structure})

Expand Down

0 comments on commit 1583f11

Please sign in to comment.