Mercurial > hgrepos > Python > libs > ConfigMix
comparison docs/introduction.rst @ 723:c17a4e30ebbf
Docs for nested filters
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Wed, 16 Aug 2023 17:04:14 +0200 |
| parents | a8bcb22341cd |
| children | 11e24e1bbf20 |
comparison
equal
deleted
inserted
replaced
| 722:ea1a6beadc6c | 723:c17a4e30ebbf |
|---|---|
| 514 | 514 |
| 515 Also available are special filter functions ``None`` and ``Empty``. | 515 Also available are special filter functions ``None`` and ``Empty``. |
| 516 They are useful in variable interpolation context because they | 516 They are useful in variable interpolation context because they |
| 517 suppress possible lookup errors (aka :py:exc:`KeyError`) and instead | 517 suppress possible lookup errors (aka :py:exc:`KeyError`) and instead |
| 518 return with :py:obj:`None` or an empty string. | 518 return with :py:obj:`None` or an empty string. |
| 519 | |
| 520 | |
| 521 Nested Interpolation (Filtering Only) | |
| 522 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 523 | |
| 524 Generally, nested interpolation does *not* work. Something like | |
| 525 ``{{{{variable}}}}`` does not work. | |
| 526 | |
| 527 Also something like ``{{{{path-variable|Empty}}/subdir|normpath}}`` does not | |
| 528 work as expected: `path-variable` would not get interpolated and `Empty` | |
| 529 not be applied. | |
| 530 | |
| 531 But -- as a special case -- a simplified form of nested evaluation is | |
| 532 implemented for filters only. Instead of using the start tag ``{{`` and end | |
| 533 tag ``}}`` it uses the special start tag ``{{|`` and end tag ``|}}``. | |
| 534 | |
| 535 | |
| 536 With the syntax:: | |
| 537 | |
| 538 {{|<expression with variables>|filter1[,filter2...]|}} | |
| 539 | |
| 540 The expression above can be expressed as | |
| 541 ``{{|{{path-variable|Empty}}/subdir|normpath|}}`` | |
| 542 and yields the expected result -- with `normpath` applied to the now | |
| 543 interpolated expression. | |
| 519 | 544 |
| 520 | 545 |
| 521 Examples | 546 Examples |
| 522 ~~~~~~~~ | 547 ~~~~~~~~ |
| 523 | 548 |
