diff --git a/api/src/reportcreator_api/tests/test_rendering.py b/api/src/reportcreator_api/tests/test_rendering.py index aa8548082..811cc87bd 100644 --- a/api/src/reportcreator_api/tests/test_rendering.py +++ b/api/src/reportcreator_api/tests/test_rendering.py @@ -80,6 +80,8 @@ def extract_html_part(self, html, start=None, end=None): ("{{ formatDate('2022-09-21', 'long', 'en-US') }}", "September 21, 2022"), ("{{ formatDate('2022-09-21', 'full', 'en-US') }}", "Wednesday, September 21, 2022"), ("{{ formatDate('2022-09-21', {year: '2-digit', month: 'narrow', day: '2-digit', numberingSystem: 'latn'}, 'en-US') }}", "S 21, 22"), + ("""
{{ helperFunction() }}
""", lambda self: f"
{self.project.data['title']} function
"), + ("""
{{ computedVar.value }}
""", lambda self: f"
{self.project.data['title']} computed
"), ]) def test_variables_rendering(self, template, html): if callable(html): diff --git a/docs/docs/designer/formatting-utils.md b/docs/docs/designer/formatting-utils.md index 707ecb205..3b792f2ce 100755 --- a/docs/docs/designer/formatting-utils.md +++ b/docs/docs/designer/formatting-utils.md @@ -76,4 +76,31 @@ English (default): ... English (no commas, always "and"): ... German: ... French: ... -``` \ No newline at end of file +``` + + +## Helper Functions +It is possible to define helper functions and variables inside the Vue template language to reuse logic. +Setting variables only works for native DOM tag (e.g. `
`, ``, etc.), but not for Vue components (e.g. `