diff --git a/.gitignore b/.gitignore index 5e5560c..5864a61 100644 --- a/.gitignore +++ b/.gitignore @@ -86,4 +86,8 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.toptal.com/developers/gitignore/api/vim,adobe,windows,macos \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/vim,adobe,windows,macos + +# Lektor plugin files +**/*.egg-info/ +**/__pycache__/ \ No newline at end of file diff --git a/packages/jinja2-filters/lektor_jinja2_fitlers.py b/packages/jinja2-filters/lektor_jinja2_fitlers.py new file mode 100644 index 0000000..9a4cf90 --- /dev/null +++ b/packages/jinja2-filters/lektor_jinja2_fitlers.py @@ -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 diff --git a/packages/jinja2-filters/setup.py b/packages/jinja2-filters/setup.py new file mode 100644 index 0000000..84ed322 --- /dev/null +++ b/packages/jinja2-filters/setup.py @@ -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=[] +)