From b732b4ceb5554bd48d25d26f5aa6f4c13ecf5f79 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 18 May 2023 00:07:19 +1000 Subject: [PATCH] Add docs for more helper functions (#4844) --- docs/docs/report/helpers.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/docs/report/helpers.md b/docs/docs/report/helpers.md index e3d53e559c..443fab8585 100644 --- a/docs/docs/report/helpers.md +++ b/docs/docs/report/helpers.md @@ -14,6 +14,34 @@ Some common functions are provided for use in custom report and label templates. !!! tip "Use the Source, Luke" To see the full range of available helper functions, refer to the source file [report.py](https://github.com/inventree/InvenTree/blob/master/InvenTree/report/templatetags/report.py) where these functions are defined! +## Data Structure Access + +A number of helper functions are available for accessing data contained in a particular structure format: + +### Index Access + +To return the element at a given index in a container which supports indexed access (such as a [list](https://www.w3schools.com/python/python_lists.asp)), use the `getindex` function: + +```html +{% raw %} +Item: {% getindex my_list 1 %} +{% endraw %} +``` + +### Key Access + +To return an element corresponding to a certain key in a container which supports key access (such as a [dictionary](https://www.w3schools.com/python/python_dictionaries.asp)), use the `getkey` function: + +```html +{% raw %} + +{% endraw %} +``` + ## Rendering Currency The helper function `render_currency` allows for simple rendering of currency data. This function can also convert the specified amount of currency into a different target currency: