Added jinja2 filters via lektor plugin to enable debug prints.
This commit is contained in:
parent
1b19f07b35
commit
3b9fc36c42
6
.gitignore
vendored
6
.gitignore
vendored
@ -86,4 +86,8 @@ $RECYCLE.BIN/
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/vim,adobe,windows,macos
|
||||
# End of https://www.toptal.com/developers/gitignore/api/vim,adobe,windows,macos
|
||||
|
||||
# Lektor plugin files
|
||||
**/*.egg-info/
|
||||
**/__pycache__/
|
28
packages/jinja2-filters/lektor_jinja2_fitlers.py
Normal file
28
packages/jinja2-filters/lektor_jinja2_fitlers.py
Normal file
@ -0,0 +1,28 @@
|
||||
from lektor.pluginsystem import Plugin
|
||||
|
||||
class Jinja2FiltersPlugin(Plugin):
|
||||
name = "Jinja2 Filters"
|
||||
description = 'Custom Jinja2 filters to use with Lektor.'
|
||||
|
||||
def on_setup_env(self, **extra):
|
||||
def shout_filter(value):
|
||||
return value.upper() + '!!!!1111'
|
||||
|
||||
self.env.jinja_env.filters['shout'] = shout_filter
|
||||
|
||||
def show_all_attrs(value):
|
||||
res = []
|
||||
for item in dir(value):
|
||||
res.append(str(item) + "\n")
|
||||
return '\n'.join(res)
|
||||
|
||||
self.env.jinja_env.filters['show_all_attrs'] = show_all_attrs
|
||||
|
||||
def show_all_vars(value):
|
||||
res = []
|
||||
attr_list = vars(value)
|
||||
for item in attr_list:
|
||||
res.append(str(item) + ': ' + str(attr_list[item]))
|
||||
return '\n'.join(res)
|
||||
|
||||
self.env.jinja_env.filters['show_all_vars'] = show_all_vars
|
13
packages/jinja2-filters/setup.py
Normal file
13
packages/jinja2-filters/setup.py
Normal file
@ -0,0 +1,13 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='lektor-jinja2-filters',
|
||||
version='0.2',
|
||||
py_modules=['lektor_jinja2_fitlers'],
|
||||
entry_points={
|
||||
'lektor.plugins': [
|
||||
'jinja2-filters = lektor_jinja2_fitlers:Jinja2FiltersPlugin',
|
||||
]
|
||||
},
|
||||
install_requires=[]
|
||||
)
|
Loading…
Reference in New Issue
Block a user