Added documentation for custom templates and improved code readability
This commit is contained in:
@@ -59,6 +59,15 @@ You can use the following variables in your template:
|
||||
``theme.name``, ``theme.url``
|
||||
Name and url of the currently used theme.
|
||||
|
||||
Filters
|
||||
~~~~~~~
|
||||
|
||||
You can define custom jinja filters for your template by creating a ``filters.py`` script
|
||||
at the root of your template directory.
|
||||
|
||||
This script will then be imported and all defined functions will be available as jinja filters
|
||||
with the same names in your templates.
|
||||
|
||||
Documentation of sigal's main classes
|
||||
-------------------------------------
|
||||
|
||||
|
||||
@@ -87,8 +87,9 @@ class Writer(object):
|
||||
filters_py = os.path.join(self.theme, 'filters.py')
|
||||
if os.path.exists(filters_py):
|
||||
mod = imp.load_source('filters', filters_py)
|
||||
for name in [name for name in dir(mod) if isinstance(getattr(mod, name), types.FunctionType)]:
|
||||
env.filters[name] = getattr(mod, name)
|
||||
for name in dir(mod):
|
||||
if isinstance(getattr(mod, name), types.FunctionType):
|
||||
env.filters[name] = getattr(mod, name)
|
||||
|
||||
try:
|
||||
self.template = env.get_template(self.template_file)
|
||||
|
||||
Reference in New Issue
Block a user