Document use of python methods in jinja

This commit is contained in:
Nathan Grennan 2017-07-17 12:24:41 -07:00 committed by GitHub
parent 0d11e1f9a2
commit 0bfc1a2fb2

View File

@ -1700,6 +1700,23 @@ Will insert the following message in the minion logs:
.. jinja_ref:: custom-execution-modules
Python methods
====================
A power feature of jinja that is only hinted at in the official jinja
documentation is that you can use the native python methods of the
variable type. Here is the python documentation for `string methods`_.
.. code-block:: jinja
{% set hostname,domain = grains.id.partition('.')[::2] %}{{ hostname }}
.. code-block:: jinja
{% set strings = grains.id.split('-') %}{{ strings[0] }}
.. _`string methods`: https://docs.python.org/2/library/stdtypes.html#string-methods
Custom Execution Modules
========================