Files
openstack-ansible-plugins/doc/source/filters.rst
Andreas Jaeger c063ad0218 Cleanup py27 support
This repo is now testing only with Python 3, so let's make
a few cleanups:
- Remove setup* files, those are not needed anymore
- Cleanup */source/conf.py to remove now obsolete content.
- remove install_cmd, move constraints into deps, cleanup
  tox.ini
- Enable warnings for docs build, fix problems

Change-Id: I3f91f00195f869c6ec09af1a88cfd189e8a71254
2020-04-27 20:23:20 +02:00

1.6 KiB

Filters

deprecated

This filter will return the old_var value, if defined, along with a deprecation warning that will inform the user that the old variable should no longer be used.

In order to use this filter the old and new variable names must be provided to the filter as a string which is used to render the warning message. The removed_in option is used to give a date or release name where the old option will be removed. Optionally, if fatal is set to True, the filter will raise an exception if the old variable is used.

old_var: "old value"
old_var_name: "old_var"
new_var_name: "new_var"
removed_in: "Next release"
fatal_deprecations: false

{{ new_var | deprecated(old_var,
                               old_var_name,
                               new_var_name,
                               removed_in,
                               fatal_deprecations) }}
# WARNING => Deprecated Option provided: Deprecated variable:
# "old_var", Removal timeframe: "Next release", Future usage:
# "new_var"
# => "old value"

splitlines

This filter will return of list from a string with line breaks.

string_with_line_breaks: |
  a string
  with
  line
  breaks

{{ string_with_line_breaks | splitlines }}
# => [ "a string", "with", "line", "breaks" ]

string_2_int

This filter will hash a given string, convert it to a base36 int, and return the modulo of 10240.

{{ 'openstack-ansible' | string_2_int }}
# => 3587