aboutsummaryrefslogtreecommitdiffstats
path: root/testing/templates/if-coerce.html
diff options
context:
space:
mode:
authorLibravatar Christian Vallentin <mail@vallentin.dev>2020-12-01 17:01:05 +0100
committerLibravatar GitHub <noreply@github.com>2020-12-01 17:01:05 +0100
commita199defeca2dfc6aa3e972acca82c96db07f99e9 (patch)
tree737d61c5e0766244e992e4f79d0311b515d1c6ec /testing/templates/if-coerce.html
parent266c606e39402a7c0cd357cdda8881e8f2ea417f (diff)
downloadaskama-a199defeca2dfc6aa3e972acca82c96db07f99e9.tar.gz
askama-a199defeca2dfc6aa3e972acca82c96db07f99e9.tar.bz2
askama-a199defeca2dfc6aa3e972acca82c96db07f99e9.zip
Improved if statement generation to avoid issues with implicit borrows (#392)
* Changed to automatically coerce to bool * Added new test case * Updated test case to include else if
Diffstat (limited to 'testing/templates/if-coerce.html')
-rw-r--r--testing/templates/if-coerce.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/templates/if-coerce.html b/testing/templates/if-coerce.html
new file mode 100644
index 0000000..e32c2fe
--- /dev/null
+++ b/testing/templates/if-coerce.html
@@ -0,0 +1,51 @@
+{% macro foo(b) -%}
+ {% if b %}t{% else %}f{% endif -%}
+{% endmacro -%}
+
+{% macro bar(b) -%}
+ {%- call foo(b) -%}
+{% endmacro -%}
+
+{% macro baz(b) -%}
+ {%- call bar(b) -%}
+{% endmacro -%}
+
+{% macro qux(b) -%}
+ {%- call baz(b) -%}
+{% endmacro -%}
+
+{%- call foo(false) -%}
+{%- call bar(true) -%}
+{%- call baz(false) -%}
+{%- call qux(true) -%}
+
+{%- call qux(true && false) -%}
+{%- call qux(false || true) -%}
+
+{%- call qux(self.t) -%}
+{%- call qux(self.f) -%}
+{%- call qux(self.f || self.t) -%}
+
+{%- if false -%}
+if
+{%- else if false || true -%}
+elseif
+{%- else -%}
+else
+{%- endif -%}
+
+{%- if true && false -%}
+if
+{%- else if false -%}
+elseif
+{%- else -%}
+else
+{%- endif -%}
+
+{%- if false || true -%}
+if
+{%- else if (true && false) -%}
+elseif
+{%- else -%}
+else
+{%- endif -%}