-
Notifications
You must be signed in to change notification settings - Fork 39
Use Jinja2's line statement features in our templates #6
Comments
i don't think it is a good idea introducing additional syntax. The Using the minuses '-' you can adjust removing white characters before or Am 19.05.2013 14:01, schrieb Electronic Kiwi:
|
This (while not being very intuitive) works most of the time. |
I would agree with this but i think if we could simplify the creation of the templates it is worth it. As you already pointed out it is hard to get the whitespaces right the way it's currently done. When this gets easier with line statements i would vote for using them. A lot of the templates are already in a matching style with one statement per line. |
Am 19.05.2013 23:49, schrieb Electronic Kiwi:
|
I tried it with '{%' as the line statement character in a mixed file (line statements and regular statements) and it did not work:
But if you change the line statement character to something else, even like '{%%' it works for me on a mixed template file. |
Electronic Kiwi wrote:
That's expected as now the "-%}" is trash at the end of the line.
I would drop the "{" as there is no matching closing bracket. |
Am 20.05.2013 18:13, schrieb Fabian Greif:
maybe something like ">" or "?" |
'>' and '?' both do not work because something like this is legal in C++:
(Not that this is nice code, but you never know, maybe someone will need to have a line break in front of a '?' or a '>' one day) I like '%%' because I already associate the '%' character with jinja2 statements. '##' would work as well, but to me it looks too much like a preprocessor macro (and isn't that also used to concatenate strings in the preprocessor?). |
Closed with commit 22cd192 |
One thing that has always bugged me about the code produced by our templates is, that:
The result that would imho best fit our style of template coding (i.e. putting jinja2 statements in a separate line) is if these lines would just be left out in the file resulting from our template.
One way I found that makes exactly this behavior possible is to use the Jinja2 Line Statements. To use this we only need to add something like this:
to the scons/site_tools/template.py file around line 80.
This change does not affect any of our existing templates it only adds the possibility to use line statements which result imho in nicer output files in our template files.
The reason I didn't just commit this to our develop branch is that I would like to hear other people's opinion on what to use as a line_statement_prefix. Personally I like '{%' which resembles the regular block statements but would also appreciate only one character if we can find one that must not be used in a new line in Cpp.
The text was updated successfully, but these errors were encountered: