remove whitespace #391
Replies: 1 comment 1 reply
-
ive added a new category "potential enhancements" for discussions like this.
as mentioned elsewhere Mako hasnt had any syntax changes in over a decade and we aren't really in a place to be rethinking things. The language is kind of brittle and even very small changes need lots of attention and testing and generally take a few years to not keep producing regressions and new issues. I also am not implementing anything for Mako other than critical bug fixes if any these days and I definitely dont have the resources to maintain major new behaviors for months/years on my own. all of that said, you can probably implement this syntax / feature yourself right now using a preprocessor function that just replaces out |
Beta Was this translation helpful? Give feedback.
-
The Template Toolkit provides an easy syntax for removing leading and trailing whitespace:
[%- instead of [% removes all whitespace (including newlines) before the directive
-%] instead of %] removes all whitespace (including newlines) after the directive
The latter is barely ever needed, but the removal of leading whitespace is very important.
This feature is missing in Mako. You can only add a backslash at the end of the line to eat the newline. But that's insufficient in several respects:
or
you get:
(because only the newline is chomped, not the spaces)
but you want:
Of course you can remove the indentation of the Mako block, but at the cost of readability.
The Template Toolkit approach would be:
Can this be implemented?
Beta Was this translation helpful? Give feedback.
All reactions