Skip to content

Commit

Permalink
Use existing module as jinja2 filter test globals (#401)
Browse files Browse the repository at this point in the history
* ✨ 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 <chfw@users.noreply.github.com>
  • Loading branch information
chfw and chfw committed Sep 10, 2020
1 parent 9a5c3f1 commit 6c17bdd
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/moban-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: '3.7'
- name: check changes
run: |
pip install moban gitfs2 pypifs moban-jinja2-github
pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible
make update
git status
git diff --exit-code
Expand Down
7 changes: 7 additions & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: moban
organisation: moremoban
releases:
- changes:
- action: Fixed
details:
- Use any functions, any data structure of any python packages
as jinja2 filters, tests, globals
date: 04.09.2020
version: 0.8.2
- changes:
- action: Fixed
details:
Expand Down
4 changes: 2 additions & 2 deletions .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ organisation: moremoban
author: chfw
contact: wangc_2011@hotmail.com
license: MIT
version: 0.8.1
current_version: 0.8.1
version: 0.8.2
current_version: 0.8.2
release: 0.8.1
branch: master
master: index
Expand Down
26 changes: 25 additions & 1 deletion .moban.d/moban_readme.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,31 @@ moban allows the injection of user preferred jinja2 extensions:

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

Can I write my own jinja2 test, filter and/or globals

Well, can I nick some existing functions as filters, tests? Or create a global from another library?
-----------------------------------------------------------------------------------------------------

Sure, you can use the same '-e' syntax:

.. code-block:: bash

$ moban -e jinja2=filter:module.path.filter_function \
jinja2=test:module.path.test_function \
jinja2=global:identifier=module.path.variable

In this case, you would have to include the external library in your own requirements.txt

Here is an example:

.. code-block:: bash

$ moban -e jinja2=filter:moban.externals.file_system.url_join \
jinja2=test:moban.externals.file_system.exists \
jinja2=global:description=moban.constants.PROGRAM_DESCRIPTION \
-t "{{ 'a'|url_join('b')}} {{'b' is exists}}"


Can I write my own jinja2 test, filter and/or globals?
-----------------------------------------------------------

moban allows the freedom of craftsmanship. Please refer to the docs for more
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Change log
================================================================================

0.8.2 - 04.09.2020
--------------------------------------------------------------------------------

**Fixed**

#. Use any functions, any data structure of any python packages as jinja2
filters, tests, globals

0.8.1 - 04.09.2020
--------------------------------------------------------------------------------

Expand Down

0 comments on commit 6c17bdd

Please sign in to comment.