-
Notifications
You must be signed in to change notification settings - Fork 447
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
PHP_EOL error when using expressions in {{ }} #1048
Comments
The EOL is only added when you have a newline after your expression. i.e. like <textarea>
{{@text}}
</textarea> instead of |
Yes, but it is expected that You could add
But i propose to add new configuration option to avoid incompatibility between versions. Edit: After some thoughts i think adding PHP_EOL is wrong, because template file could use non standard EOL like CRLF on Linux hosts. It could fix some very basic case, but is not good general way of fixing problem. |
fixed in f3-factory/fatfree-core@d5fb7fc |
No, it is not fixed. Adding PHP_EOL (LF) on Linux host mangle files which has Windows EOLs (CRLF), which is required for many file types. Fix of: f3-factory/fatfree-core#205 just created another class of problems. But it could be this way if anyone could disable this functionality by setting core variable, which now is not possible. Changing critical core internals without giving compatibility options to set them back is very bad way to develop software. It's my 2 cents... |
Don't get me wrong, but the |
It is not inserting EOLs in PHP template, but in result file, and i'm using templating not only for sending to browser, but many more like generating company internal XMLs and prepared SMTP commands (which both requires CRLFs and i'm on Linux host). |
Alright, the lastest commit doesn't use PHP_EOL anymore. |
Dear Christian :). |
Thanks for criticizing all of my changes. I'm just trying to understand your point, since I do not think that a config option would be useful for anyone, but you (maybe). The point is that when you i.e. render a config file like this (or SMTP command sheet, etc) [usercfg]
var1 = {{ @var1 }}
var2 = {{ @var2 }}
var3 = {{ @var1 }}
var4 = {{ @var2 }} the result with your proposed option turned OFF would be:
It seems to me that this is what you want, right? In fact, when you |
First, I apologize, if i was being rude. What You have written is what i expect - it is well known PHP behaviour (bad or good - not worth to discuss about it) and fighting with by solving one problem, it brings more problems to solve then. Of course You and many more can find this functionality useful. |
Here's a suggestion for a config option for this behaviour, f3-factory/fatfree-core#223 |
Thanks a lot. I appreciate Your effort :). |
Thanks @ikkez for digging into this and bringing the appropriate fixes. @SylwesterZarebski can you please give a short code example where disabling the "interpolation" behaviour would be useful? I just can't figure it out. |
The need for 'option' is compatibility:
I.e. i have a template which has CRLFs which is converted from plain PHP and now looks like this:
year ago it looks almost the same:
It works in previous framework versions. Now with internal framework changes i should convert all the templates to remove additional CRLF. When i want to go back to plain PHP i need to add these CRLFs once more. PS. In general, i think the problem is why that serious change sneak into release version, when should not, because it fundamentally changes how templates works. I'm not expecting that kind of changes in bugfix/release line of development (3.6.x vs 3.7.x vs 4.0.x and so on), because i'm expecting, when i regularly change framework to new version in the same line, nothing breaks (modulo bugs of course). |
Ok. I just understood how PHP ending tags swallow EOLs. For some reason, I didn't suspect it was that bad. So if we have:
PHP renders (with
Now testing a similar F3 template:
F3 3.6.1 rendered the template like PHP does:
while F3 3.6.2 "fixes" that weird behaviour:
I like the way 3.6.2 renders templates without swallowing EOLs (like I would expect PHP to do). But I also understand that some devs may have reasons to stick to PHP rendering logic. So 👍 for f3-factory/fatfree-core#223 |
@SylwesterZarebski you wrote:
We all expect the same. The thing is that nobody suspected the backwards compatibility break when fixing f3-factory/fatfree-core#205. |
Thanks a lot for understanding. I really appreciate Your effort. |
I have a problem with newest 3.6.2 version which changed building template's lines.
With this version all lines get PHP_EOL on end which bring error in lines like:
Compiled line is:
And error is:
Fatal error: syntax error, unexpected 'PHP_EOL' (T_STRING), expecting ',' or ';'
I have added temporary parentheses around expression, but i should not do that.
Problem looks like is effect of fix: f3-factory/fatfree-core#205
Besides, You should not add artificial EOLs, and consider removing PHP_EOL, because:
a) EOLs are unwelcomed in some situations - like TEXTAREA
b) it is inconsistent with PHP, which do not output EOLs after ?>
c) it should be user responsible to generate proper template
PS. Could it be framework configuration for adding or not EOLs?
The text was updated successfully, but these errors were encountered: