We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Formatter inserts space when directly indexing a list returned by a function. To wit:
djlint --check --profile=jinja templates/list_element.j2 Checking 1/1 files ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 00:00 templates/list_element.j2 ──────────────────────────────────────────────────── @@ -1,6 +1,5 @@ {% set item_list = ["1", "4", "9"] %} * Item: {{ item_list[2] }} - {% set item = item_list[2] + "/cidr_thing" %} -New Val[1]: {{ item.split("/")[1] }} -New Val.1: {{ item.split("/").1 }} +New Val[1]: {{ item.split("/") [1] }} <== This +New Val.1: {{ item.split("/") .1 }}. <== And also this 1 file would be updated.
This doesn't break rendering, but djlint's behavior seem wrong to me; foo.function(args)[index] is, as far as I know, a valid construct.
Script:
#!/usr/bin/env python3 import sys import argparse import jinja2 def handle_arguments(): parser = argparse.ArgumentParser() parser.add_argument('template') return parser.parse_args() def main(args: argparse.Namespace): template = jinja2.Environment( loader=jinja2.FileSystemLoader("templates"), trim_blocks=True, lstrip_blocks=True, ).get_template(args.template) print(template.render()) if __name__ == '__main__': parsed_args = handle_arguments() sys.exit(main(parsed_args))
Template:
{% set item_list = ["1", "4", "9"] %} * Item: {{ item_list[2] }} {% set item = item_list[2] + "/cidr_thing" %} New Val[1]: {{ item.split("/")[1] }} New Val.1: {{ item.split("/").1 }}
The text was updated successfully, but these errors were encountered:
a197200
chore(release): 1.31.1 [skip ci]
7366ed5
## [1.31.1](v1.31.0...v1.31.1) (2023-06-26) ### Bug Fixes * **formatter:** fixed formatter formatting ignored code ([5c75d87](5c75d87)), closes [#655](#655) * **formatter:** fixed function formatting with nested quoted parenthesis ([6d63a6a](6d63a6a)), closes [#698](#698) * **formatter:** fixed overgrabbing on template tag condensing ([75c3134](75c3134)), closes [#686](#686) * **formatter:** function index was not formatted correctly ([a197200](a197200)), closes [#693](#693)
🎉 This issue has been resolved in version 1.31.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
Sorry, something went wrong.
Confirmed on this end; thanks.
No branches or pull requests
System Info
Issue
Formatter inserts space when directly indexing a list returned by a function. To wit:
This doesn't break rendering, but djlint's behavior seem wrong to me; foo.function(args)[index] is, as far as I know, a valid construct.
How To Reproduce
Script:
Template:
The text was updated successfully, but these errors were encountered: