-
Notifications
You must be signed in to change notification settings - Fork 0
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
whitespace control #4
Comments
To be honest I would instead add manual whitespace control for the tag delimiters. E.g. similar to Twig, {- would eat all whitespaces before the tag, -} after the tag. Also it would be possible to make the tag closing delimiter eat one newline character but automatic strategies may not work well. Needs further thought on my part. |
Implemented using E.g. Still thinking about removing only the extraneous newlines. |
Many thanks. Is it better to use \n instead of \s? Most people like formatted html. Whitespace control is really a hard thing. |
Please explain, what you mean by \n instead of \s. We could change the pattern but I believe that \s is a good enough choice to trim with. |
Totally agree. For \n instead of \s, use my example above again. source:
output(should be, not tested):
expected:
more readable, is it? |
Well, if you expect the secound output, simply modify your template to this (note the missing
If you'd modified the \s to \n, your output would simply be everything in a one-line mess. |
Thanks. Didn't realize it:( my bad. By the way, how about adding it as an option, like auto-trim or auto-strip? Type one more hyphen - is very annoying. |
I could add an option to trim the first newline after the closing delimiter, just like PHP does it. Also I could add an invert-switch to make the hyphen not to trim whitespaces and the default delimiter to trim. |
From now on you'll be able to: |
Thanks!!! For tag_consumes_newline option, its better to skip include (maybe block as well) tag. header:
example:
output:
expected:
|
First of all, your example is wrong. :-) Actual output would be:
Also it depends. It is recommended to put a newline character at the end of each file. That would mean that the include tag strips the newline but the included template adds it back. Also, block, define and include are especially problematic. When a larger template (one with more than 1 lines) is included, it will most likely be indented in a wrong way. Using blocks, the first line would be at the right indentation level, the rest would not and this is a problem that makes it really hard to make nice html output.
Output:
|
better to remove all blank lines inside the for tags. (not sure if it exists in other tags as well)
for example:
delimiters: '<{', '}>'
template source:
actual output:
expected:
whitespaces before and after the block tags should be suppressed:)
The text was updated successfully, but these errors were encountered: