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

Make fixture test templates "pretty" #1203

Merged
merged 3 commits into from
Sep 12, 2024
Merged

Conversation

jasmith-hs
Copy link
Contributor

@jasmith-hs jasmith-hs commented Sep 11, 2024

Allows fixture templates to be separated by newlines for easier readability.
Use \ to escape the newlines similar to escaping in bash scripts.

Certainly this:

{% do __temp_import_alias_902286926__.update({'import_resource_path': 'macro-and-set.jinja'}) %}\
{% endfor %}\
{% set simple = __temp_import_alias_902286926__ %}\
{% set current_path = '' %}\
{% enddo %}\
simple.foo: {% set deferred_import_resource_path = 'macro-and-set.jinja' %}\
{% macro simple.foo() %}\
Hello {{ myname }}\
{% endmacro %}\
{% set deferred_import_resource_path = null %}\
{{ simple.foo() }}

Is easier to read than this:

{% do __temp_import_alias_902286926__.update({'import_resource_path': 'macro-and-set.jinja'}) %}{% endfor %}{% set simple = __temp_import_alias_902286926__ %}{% set current_path = '' %}{% enddo %}simple.foo: {% set deferred_import_resource_path = 'macro-and-set.jinja' %}{% macro simple.foo() %}Hello {{ myname }}{% endmacro %}{% set deferred_import_resource_path = null %}{{ simple.foo() }}

The actual output may not have any newlines in it, but for writing, understanding, and debugging test failures, splitting up the jinjava nodes with newlines is very helpful. And the \ denotes that the pretty spacing is not actually part of the output.

@jasmith-hs jasmith-hs merged commit 9742adf into master Sep 12, 2024
5 checks passed
@jasmith-hs jasmith-hs deleted the pretty-test-templates branch September 12, 2024 12:43
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