# HG changeset patch # User Franz Glasner # Date 1624556360 -7200 # Node ID a7491f835cb021f1ecb9e3bc12288e8595676511 # Parent 2b209bdf6995d570d4d4740ddd5868f347449090 Changelog and minimal docu for `None` and `Empty` filters diff -r 2b209bdf6995 -r a7491f835cb0 CHANGES.txt --- a/CHANGES.txt Thu Jun 24 19:26:53 2021 +0200 +++ b/CHANGES.txt Thu Jun 24 19:39:20 2021 +0200 @@ -18,6 +18,12 @@ - **[feature]** New filter function :py:func:`urlquote_plus` +- **[feature]** + New filter functions :py:func:`None` and :py:func:`Empty`. They are + useful in variable interpolation context where they suppress possible + lookup errors (aka :py:exception:`KeyError`) and instead return with + :py:obj:`None` or an empty string. + 0.14 (2021-05-10) ~~~~~~~~~~~~~~~~~ diff -r 2b209bdf6995 -r a7491f835cb0 docs/introduction.rst --- a/docs/introduction.rst Thu Jun 24 19:26:53 2021 +0200 +++ b/docs/introduction.rst Thu Jun 24 19:39:20 2021 +0200 @@ -417,6 +417,11 @@ ``upper`` +Also available are special filter functions ``None`` and ``Empty``. +They are useful in variable interpolation context because they +suppress possible lookup errors (aka :py:exception:`KeyError`) and +instead return with :py:obj:`None` or an empty string. + Examples ~~~~~~~~ @@ -453,13 +458,13 @@ With ``{{ref:#my.other.key}}`` -- think of it as a sort of a symbolic link to other parts of the +- think of it as a sort of a symbolic link to other parts of the configuration tree - by employing the special namespace ``ref`` - can not be quoted currently in variable interpolation syntax - No special handling when merging is done -- merging is agnostic of tree references -- Keys within :meth:`.Configuration.getvar_s`, +- Keys within :meth:`.Configuration.getvar_s`, :py:meth:`.Configuration.getvar`, :py:meth:`.Configuration.getvarl` and :py:meth:`.Configuration.getvarl_s` are handled - in :py:meth:`.Configuration.getvar` only, when it is the directly