Last active
March 2, 2020 16:07
-
-
Save miguel-amaral/6b2231cd28e4889fdcf2151fd7f5584c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# This is a comment #} | |
{# This Template is being used with app local_meza_backend #} | |
{# This ensures that the variables inside the [] exist #} | |
{# We do it this way in order to achieve a pretty error message: "awkard_variable" is not set #} | |
{% set mandatory_variables = [number_to_check, app_name] %} | |
{% if random_variable_that_does_not_exist %} | |
random_variable_that_does_not_exist is true | |
{% else %} | |
random_variable_that_does_not_exist is false | |
{% endif %} | |
{# This Block is ok #} | |
{% set percentage_sign = '%' %} | |
potato{{ percentage_sign }} - without a space | |
potato {{ percentage_sign }} with a space | |
percent -> '%' | |
{{ app_name }} | |
{{ will_fail }} | |
{% for i in range(0, 6, 2) %} | |
{{ i }}, | |
{% endfor %} | |
{% flush %} | |
{# This Block is ok #} | |
{% if 99 is odd %} | |
'Hardcoded' - 99 is odd | |
'number_to_check' - {{ number_to_check }} is odd | |
{% endif %} | |
{# This Block is ok #} | |
{% if number_to_check %} | |
number_to_check is an existing variable: {{ number_to_check }} | |
{% endif %} | |
{# This Block is ok #} | |
{% if number_to_check == 10 %} | |
number_to_check is 10 | |
{% elseif number_to_check == "sports" %} | |
number_to_check is sports | |
{% else %} | |
number_to_check is not '10' nor 'sports' | |
{% endif %} | |
{% if number_to_check == 10 %} | |
{{ awkard_variable_that_does_not_exist }} | |
{% endif %} | |
{% if awkard_variable_that_does_not_exist is not defined %} | |
awkard_variable_that_does_not_exist is not defined | |
{% endif %} | |
{# Test an existing #} | |
{% for var in mandatory_variables %} | |
{{ var }}, | |
{% endfor %} | |
{# Test defaults #} | |
{{ this_does_not_exist | default("This is a default String") }} | |
{{ this_does_not_exist | default(456) }} | |
{{ app_name | default("This test should never appear as the var app_name is always defined") }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment