aboutsummaryrefslogtreecommitdiffstats
path: root/testing/templates
diff options
context:
space:
mode:
authorLibravatar mataha <mataha@users.noreply.github.com>2023-06-10 04:57:56 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-06-12 10:35:40 +0200
commitcba1fb8e508eae87d213e7bc4c7b2eb8b4b92732 (patch)
tree36fd43629c3686e2e630db884f5c5379d9c55246 /testing/templates
parentfe5d350f50ebc73300456c618dd265cc43a8f05a (diff)
downloadaskama-cba1fb8e508eae87d213e7bc4c7b2eb8b4b92732.tar.gz
askama-cba1fb8e508eae87d213e7bc4c7b2eb8b4b92732.tar.bz2
askama-cba1fb8e508eae87d213e7bc4c7b2eb8b4b92732.zip
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 <mataha@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r--testing/templates/macro-no-args.html21
1 files changed, 21 insertions, 0 deletions
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