diff --git a/docs/themes.rst b/docs/themes.rst index 1a206c2..26a3951 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -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 ------------------------------------- diff --git a/sigal/writer.py b/sigal/writer.py index d2b566f..c8a1df4 100644 --- a/sigal/writer.py +++ b/sigal/writer.py @@ -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)