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

Option to always chomp whitespace #499

Open
alanwsmith opened this issue Apr 23, 2024 · 3 comments
Open

Option to always chomp whitespace #499

alanwsmith opened this issue Apr 23, 2024 · 3 comments

Comments

@alanwsmith
Copy link

I'm using lstrip_blocks and set_trim_blocks to help with white space, but it's still bugs me and I end up with a lot of manual removal by adding -

I'd like to request a feature to treat every tag and expression as if it started and ended with - to remove the white space beside them. The idea is to then use something like {{ ' ' }} explicitly when you need a space. The feature could be a function called set_collapse_spaces

I'm happy to put in work to help make this happen if it's acceptable

@mitsuhiko
Copy link
Owner

I'm not super sure how to feel about this as it adds functionality that goes beyond the scope of what's also in Jinja2. That said, I'm not entirely opposed to it.

@alanwsmith
Copy link
Author

right on. I'll take a look and see what I can figure out. My use case is that I'm making a website builder that's using minijinja. I'd like to make the output a little easier for new folks to look at.

My idea is to collapse everything and then explicitly put in spaces/newlines.

I'm not entirely sure it'll be any better, but I think it's worth a look.

@alanwsmith
Copy link
Author

(I'm also looking for a rust pretty-print html option that might be another approach. I'm not having luck on that front yet. It feels like I have to be missing something, so I'm still digging into that too)

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

No branches or pull requests

2 participants