Skip to content

Commit 6c17bdd

Browse files
authored
Use existing module as jinja2 filter test globals (#401)
* ✨ the prototype to load existing filters, tests, globals from other ready made libraries, i.e. ansible. such a feature will remove the need of moban-ansible, moban-xxxx. * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 🐛 remove bugs * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 🐛 add moban-ansible dependencies * 📚 update change log * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 🔬 regression tests plus documentation * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 💄 update coding style per latest black v20.8b1 * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 💄 update changelog yaml * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 💄 make yamllint happy * 💚 make unit test pass in py3.8 Co-authored-by: chfw <[email protected]>
1 parent 9a5c3f1 commit 6c17bdd

File tree

17 files changed

+240
-251
lines changed

17 files changed

+240
-251
lines changed

.github/workflows/moban-update.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
python-version: '3.7'
1515
- name: check changes
1616
run: |
17-
pip install moban gitfs2 pypifs moban-jinja2-github
17+
pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible
1818
make update
1919
git status
2020
git diff --exit-code

.moban.cd/changelog.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: moban
22
organisation: moremoban
33
releases:
4+
- changes:
5+
- action: Fixed
6+
details:
7+
- Use any functions, any data structure of any python packages
8+
as jinja2 filters, tests, globals
9+
date: 04.09.2020
10+
version: 0.8.2
411
- changes:
512
- action: Fixed
613
details:

.moban.cd/moban.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ organisation: moremoban
44
author: chfw
55
66
license: MIT
7-
version: 0.8.1
8-
current_version: 0.8.1
7+
version: 0.8.2
8+
current_version: 0.8.2
99
release: 0.8.1
1010
branch: master
1111
master: index

.moban.d/moban_readme.jj2

+25-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,31 @@ moban allows the injection of user preferred jinja2 extensions:
139139

140140
$ moban -e jj2=jinja2_time.TimeExtension ...
141141

142-
Can I write my own jinja2 test, filter and/or globals
142+
143+
Well, can I nick some existing functions as filters, tests? Or create a global from another library?
144+
-----------------------------------------------------------------------------------------------------
145+
146+
Sure, you can use the same '-e' syntax:
147+
148+
.. code-block:: bash
149+
150+
$ moban -e jinja2=filter:module.path.filter_function \
151+
jinja2=test:module.path.test_function \
152+
jinja2=global:identifier=module.path.variable
153+
154+
In this case, you would have to include the external library in your own requirements.txt
155+
156+
Here is an example:
157+
158+
.. code-block:: bash
159+
160+
$ moban -e jinja2=filter:moban.externals.file_system.url_join \
161+
jinja2=test:moban.externals.file_system.exists \
162+
jinja2=global:description=moban.constants.PROGRAM_DESCRIPTION \
163+
-t "{{ 'a'|url_join('b')}} {{'b' is exists}}"
164+
165+
166+
Can I write my own jinja2 test, filter and/or globals?
143167
-----------------------------------------------------------
144168

145169
moban allows the freedom of craftsmanship. Please refer to the docs for more

CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Change log
22
================================================================================
33

4+
0.8.2 - 04.09.2020
5+
--------------------------------------------------------------------------------
6+
7+
**Fixed**
8+
9+
#. Use any functions, any data structure of any python packages as jinja2
10+
filters, tests, globals
11+
412
0.8.1 - 04.09.2020
513
--------------------------------------------------------------------------------
614

0 commit comments

Comments
 (0)