I had a hard time to get the desired result out of my template into a form which fits our codingstyle. I use jinja to generate C code. But in C empty lines should be preserved as much as possible to increase readebility. And while I'm not only generate C code but C header files which will be installed, these empty lines are of high value for our project. Unfortunately, the \s in pythons re engine also matches \n, thus any jinja token also eats up its leading empty lines.
This pull request includes my current solution to this problem. It lets the user specify what whitespace is. In my project I just use [ \t].
Use kwargs when instanciating the Environment.
This protects for failures, when adding new keywords.
Specify what whitespace is.
Unfortunately \s in pythons re engine also matches newlines. This makes
it very hard to use jinja where empty lines are of value. Let the user
specify what whitespace is.
@mitsuhiko Is there any chance of this being accepted? Looks like otf2 is now shipping a bundled version of jinja2 with this applied. It would be nice to not have forked versions out in the wild if it could be avoided.
Is there any chance that this is not necessary with the new lstrip changes?