-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Add suppress_whitespace config option and add config
parameter to the derive macro
#664
Conversation
4efa301
to
3b4b4c8
Compare
Fixed the typos. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see the earlier discussion in #598? In addition to the smaller questions below, I'm not sure I like the specified behavior much where the only effect of a -
when automatic_block_trim
is enabled is to disable the trim on the other side of the block. IMO the design I think we discussed earlier where a +
could be added to locally revert the default seems much clearer, since it is explicit and does not cause sort spooky action at a distance (even if the distance is limited).
What do you think? I forget what Jinja and Tera do exactly...
I just checked and they indeed use Btw, what do you think of the new derive template argument? |
I think adding a |
Thanks for confirming. Then I'll make the changes as soon as possible. |
3b4b4c8
to
ec1f380
Compare
Updated! Little sum up of what I did:
|
Sounds great! I'll review this tomorrow. |
ec1f380
to
cf8dcc1
Compare
config
parameter to the derive macroconfig
parameter to the derive macro
Applied suggestions! |
cf8dcc1
to
5f7dcaa
Compare
Fixed the invalid rebase. Sorry for the noise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
@Kijewski @vallentin any opinions? |
Any news here? :) |
Given that it's been the Easter weekend, I'll give them like 24 more hours to respond. :) |
That is a very good point. We'll see if they survived the chocolate day. 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the direction this is heading. Unless I'm misinterpreting something, and please correct me if I am. For HTML I'd love if it was possible to say "Trim all but 1 space". Given that in HTML <span>Foo</span><span>Bar</span>
vs <span>Foo</span> <span>Bar</span>
are rendered differently.
While <span>Foo</span> <span>Bar</span>
, <span>Foo</span> <span>Bar</span>
, <span>Foo</span>\n\n<<span>Bar</span>
, <span>Foo</span>\n\n \n \n\n\n<span>Bar</span>
are all rendered the same.
Anyways, this is more of a side-comment, but a feature I'd love to see extended later :)
It only impacts jinja block, not pure HTML. So unless you have a jinja block between your two |
Yeah, I interpreted that much. But as in example, I have some loops like |
Absolutely! But if you want to keep them, you can use |
Yeah, of course, and it's really nice, don't get me wrong :) My point was "a feature I'd love to see extended later". I'd love to see an extension of this feature in the future, where it would be possible to configure, so it trims all but 1 space between all "items" :) |
Oh I see. Sorry I misunderstood your point. Yes, it would be a nice extension! Don't forget to open an issue so it's not forgotten. 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, and the implementation looks good to me. Nice!
Thanks a lot everyone for the careful reviews and suggestions, it was very nice contributing here! I'll try to take a look at @vallentin's suggestion too. |
@GuillaumeGomez thanks to you for doing the work on this change and dealing with my feedback! |
I recently disovered in jinja (with Flask in python) that we could enable
automatic_block_trim
, allowing us to remove all the-
and also preventing us to forget them. I saw it was missing in this crate so I thought it'd be a good addition.So now, about the newly added
config
parameter in the derive macro: I realized when writing the tests that I couldn't have a specific configuration for a given test, making it quite complex. So the easiest solution was to create this new parameter. If you prefer, I can open a separate PR for it (its implementation is in the second commit). Of course, it's only if both features make sense to you.Finally: I didn't find out where to put the documentation for
config
. Do you have a suggestion?In any case: thanks a lot for writing this crate! It's really nice to use.