From eb8c875853b70f5da45c52b7e0b2a38015142013 Mon Sep 17 00:00:00 2001 From: Ilya Puchka Date: Sat, 5 May 2018 23:33:11 +0100 Subject: [PATCH] docs: Update documentation (#213) * Update documentation * Update builtins.rst --- docs/builtins.rst | 48 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/docs/builtins.rst b/docs/builtins.rst index c1f46ad..9d61eca 100644 --- a/docs/builtins.rst +++ b/docs/builtins.rst @@ -28,6 +28,18 @@ The ``for`` tag can iterate over dictionaries.
  • {{ key }}: {{ value }}
  • {% endfor %} + +It can also iterate over ranges, tuple elements, structs' and classes' stored properties (using ``Mirror``). + +You can iterate over range literals created using ``N...M`` syntax, both in ascending and descending order: + +.. code-block:: html+django + + The ``for`` tag can contain optional ``where`` expression to filter out elements on which this expression evaluates to false. @@ -59,6 +71,7 @@ The for block sets a few variables available within the loop: - ``last`` - True if this is the last time through the loop - ``counter`` - The current iteration of the loop (1 indexed) - ``counter0`` - The current iteration of the loop (0 indexed) +- ``length`` - The total length of the loop For example: @@ -281,7 +294,7 @@ Built-in Filters ~~~~~~~~~~~~~~ The capitalize filter allows you to capitalize a string. -For example, `stencil` to `Stencil`. +For example, `stencil` to `Stencil`. Can be applied to array of strings to change each string. .. code-block:: html+django @@ -291,7 +304,7 @@ For example, `stencil` to `Stencil`. ~~~~~~~~~~~~~ The uppercase filter allows you to transform a string to uppercase. -For example, `Stencil` to `STENCIL`. +For example, `Stencil` to `STENCIL`. Can be applied to array of strings to change each string. .. code-block:: html+django @@ -301,7 +314,7 @@ For example, `Stencil` to `STENCIL`. ~~~~~~~~~~~~~ The uppercase filter allows you to transform a string to lowercase. -For example, `Stencil` to `stencil`. +For example, `Stencil` to `stencil`. Can be applied to array of strings to change each string. .. code-block:: html+django @@ -326,4 +339,31 @@ Join an array of items. {{ value|join:", " }} -.. note:: The value MUST be an array. +.. note:: The value MUST be an array. Default argument value is empty string. + +``split`` +~~~~~~~~~ + +Split string into substrings by separator. + +.. code-block:: html+django + + {{ value|split:", " }} + +.. note:: The value MUST be a String. Default argument value is a single-space string. + +``indent`` +~~~~~~~~~ + +Indents lines of rendered value or block. + +.. code-block:: html+django + + {{ value|indent:2," ",true }} + +Filter accepts several arguments: + +* indentation width: number of indentation characters to indent lines with. Default is ``4``. +* indentation character: character to be used for indentation. Default is a space. +* indent first line: whether first line of output should be indented or not. Default is ``false``. +