-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
gcode_macro: Enable jinja2.ext.do extension #5149
Conversation
This adds a 'do' tag that works like a normal expression but ignores the return value. Useful for avoiding running the output of an expression as a command. Signed-off-by: Morten Lindhardt <[email protected]>
Signed-off-by: Morten Lindhardt [email protected]
I use the workaround normally |
That's the workaround I'm using for now too. Funnily enough, I was working on a flexplate system very similar to yours when I ran into this 😅 |
Maybe that helps, here is a real live example (the complete macros can be found https://github.com/zellneralex/klipper_config/blob/master/flexplate.cfg This is how we need to solve it currently:
It works with the work around mentioned already. After the PR would be merged it will look like:
So the change looks small but believe me as a person answers a lot of question about macros and the examples I provide I would appreciate this change since it makes it clearer what happens in that lines. BTW testet in a python2 and python3 env |
FWIW, I just found myself in need of this today, so it definitely seems like a good idea (and seems very low risk). Some minor suggestions: Commit messages should be wrapped at 75 characters or less, and if this were my PR I'd just squash it into a single commit while fixing the log entry and then do a force push. (That just makes it easier to land.) |
Thanks. I understand this proposal; however I don't currently agree with it. I agree that the Jinja2 syntax is cryptic and can be hard to use. Using Jinja2 was always a compromise - as crytpic as it is, it was better than creating a completely new "roll your own" cryptic programming language. So, I agree that So, my preference at this time is to try to keep the Jinja2 usage as simple as possible. Yes, it has issues, but I fear adding complexity risks making it even worse. -Kevin |
This PR is being closed because it is currently not considered a good match for the master Klipper repository. Best regards, PS: I'm just an automated script, not a human being. |
This adds a 'do' tag that works like a normal expression but ignores the return value.
Useful for avoiding running the output of an expression as a command when it is the only thing on a line.
Example scenarios:
Without extension enabled:
Console output:
Unknown command:"NONE"
Klippy error:
TemplateSyntaxError: Encountered unknown tag 'do'.
With extension enabled:
No console output
I don't know how needed this is since I couldn't find anyone else complaining about
Unknown command:"NONE"
in the console, and there are workarounds to avoid it ({% set _ = [1,2].append(3) %}
) but it is a very simple feature so it shouldn't hurt anything.Signed-off-by: Morten Lindhardt [email protected]