mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Document use of python methods in jinja
This commit is contained in:
parent
0d11e1f9a2
commit
0bfc1a2fb2
@ -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
|
||||
========================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user