1
0
Fork 0
forked from github/pelican

Add settings for custom Jinja globals and tests (#2715)

Pelican has a setting for custom Jinja filters but not custom tests or
custom environment namespace globals. This adds both of the latter.
This commit is contained in:
Justin Mayer 2020-04-12 17:03:53 +02:00 committed by GitHub
commit 7d19bcf5d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 2 deletions

View file

@ -78,6 +78,14 @@ class Generator(object):
custom_filters = self.settings['JINJA_FILTERS']
self.env.filters.update(custom_filters)
# get custom Jinja globals from user settings
custom_globals = self.settings['JINJA_GLOBALS']
self.env.globals.update(custom_globals)
# get custom Jinja tests from user settings
custom_tests = self.settings['JINJA_TESTS']
self.env.tests.update(custom_tests)
signals.generator_init.send(self)
def get_template(self, name):