From cba1fb8e508eae87d213e7bc4c7b2eb8b4b92732 Mon Sep 17 00:00:00 2001 From: mataha Date: Sat, 10 Jun 2023 04:57:56 +0200 Subject: Allow macros to be defined and called without arguments This commit introduces a shorthand for defining and calling macros when using them as a reusable substitute for variables assigned complex values (e.g. string literals with or without newline escapes). The use-case is formatting - from my experience it's easier to visually parse a `macro` `endmacro` block than a multiline variable assignment. Signed-off-by: mataha --- testing/templates/macro-no-args.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 testing/templates/macro-no-args.html (limited to 'testing/templates') diff --git a/testing/templates/macro-no-args.html b/testing/templates/macro-no-args.html new file mode 100644 index 0000000..b70ee8c --- /dev/null +++ b/testing/templates/macro-no-args.html @@ -0,0 +1,21 @@ +1 + +{%- macro empty -%} +the best thing +{%- endmacro -%} + +1 + +{%- call empty() -%} + +1 + +{%- macro whole() -%} +we've ever done +{%- endmacro -%} + +11 + +{%- call whole -%} + +11 -- cgit