mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add JINJA_TESTS to use custom Jinja2 tests. Refs #1498
This commit is contained in:
parent
8519ccf18c
commit
800c3c1013
3 changed files with 6 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ Setting name (followed by default value, if any)
|
|||
control data. For example: ``[".hg", ".git", ".bzr"]``
|
||||
``JINJA_EXTENSIONS = []`` A list of any Jinja2 extensions you want to use.
|
||||
``JINJA_FILTERS = {}`` A dictionary of custom Jinja2 filters you want to use.
|
||||
``JINJA_TESTS = {}`` A dictionary of custom Jinja2 tests you want to use
|
||||
The dictionary should map the filtername to the filter function.
|
||||
For example: ``{'urlencode': urlencode_filter}``
|
||||
See `Jinja custom filters documentation`_.
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ class Generator(object):
|
|||
custom_filters = self.settings['JINJA_FILTERS']
|
||||
self.env.filters.update(custom_filters)
|
||||
|
||||
# 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):
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ DEFAULT_CONFIG = {
|
|||
'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'],
|
||||
'JINJA_EXTENSIONS': [],
|
||||
'JINJA_FILTERS': {},
|
||||
'JINJA_TESTS': {},
|
||||
'LOG_FILTER': [],
|
||||
'LOCALE': [''], # defaults to user locale
|
||||
'DEFAULT_PAGINATION': False,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue