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

[BUG] [Formatter] Nunjucks function expressions have incorrect indent #808

Open
3 tasks done
Sahabial opened this issue Jan 25, 2024 · 0 comments
Open
3 tasks done
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@Sahabial
Copy link

Sahabial commented Jan 25, 2024

System Info

  • OS: windown 10
  • Python Version (3.12.1)
  • djLint Version (1.34.1)
  • template language: nunjucks

Issue

I get incorrect indentations in {{ }} expression when formatting njk files with djlint.
The only workaround I have for now is keep preserve_leading_space to true but i actually want them to be formatted as well.

I also tried online version and got the same result.

Don't know is it something with my config or with djlint. Please help. Looks like this is the only solution for now to format nunjucks templates.

How To Reproduce

.djlintrc:

{
  "extension": "njk",
  "profile": "nunjucks",
  "indent": 4,
  "no_function_formatting": false,
  "preserve_leading_space": false
}

command:
djlint ./src --reformat --configuration .djlintrc

sample input:

<div>
    {% if apos %}
		{{ apos.singleton(data.global, "footerHead", 'apostrophe-rich-text', {
			toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink' ],
			styles: [
				{
					name: 'footerHead',
					element: 'div',
					attributes: { class: 'footer--title-main'}
				}
			]
		}) }}
    {% endif %}
</div>
<div>
	{{ funct({
		test: 'best',
				jest: 'test',
		fest: 'pest'}) }}
</div>

output:

<div>
    {% if apos %}
        {{ apos.singleton(data.global, "footerHead", 'apostrophe-rich-text', {
                toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink' ],
                styles: [
                {
                name: 'footerHead',
                element: 'div',
                attributes: { class: 'footer--title-main'}
                }
                ]
                }) }}
    {% endif %}
</div>
<div>{{ funct({"test": "best", "jest": "test", "fest": "pest"}) }}</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

1 participant