Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite default template to handle nested ifs, != and env vars in if #497

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

erijo
Copy link
Collaborator

@erijo erijo commented Oct 27, 2024

What does this PR do?

Includes are now handled in the same way as the main file which means that included files can both include other files and have if statements in addition to variables (fixes #406). Include lines can now also have optional whitespace before {%.

All variables are handled in the same way now so it's now possible to use env variables in if statements (fixes #488).

Also add support for != in addition to == (fixes #358). Thus it's now e.g. possible to check if a variable is set (#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

A non-existing yadm or env variable is now replaced with the empty string.

What issues does this PR fix or reference?

#358
#406
#436
#477
#488

Previous Behavior

See above.

New Behavior

See above.

Have tests been written for this change?

Yes

Have these commits been signed with GnuPG?

Yes


Please review yadm's Contributing Guide for best practices.

The awk script now performs all processing in the BEGIN block using an
implementation that is capable of handling if statements which contain nested
if statments (fixes yadm-dev#436). To make nested ifs look better, if, else and endif
lines can now have optional whitespace before {%.

Includes are now handled in the same way as the main file which means that
included files can both include other files and have if statements in addition
to variables (fixes yadm-dev#406). Include lines can now also have optional whitespace
before {%.

All variables are handled in the same way now so it's now possible to use env
variables in if statements (fixes yadm-dev#488).

Also add support for != in addition to == (fixes yadm-dev#358). Thus it's now
e.g. possible to check if a variable is set (yadm-dev#477) by doing:

{% if yadm.class != ""%}
Class is set to {{ yadm.class }}
{% endif %}

A non-existing yadm or env variable is now replaced with the empty string.
@erijo erijo merged commit d74a41b into yadm-dev:develop Nov 6, 2024
1 check passed
@erijo erijo deleted the template-default branch November 6, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant