-
Notifications
You must be signed in to change notification settings - Fork 709
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
Removing end of lines #555
Comments
Cannot reproduce. My output has |
Hi, Sorry for the delay. In the last version the example I gave you works correctly, but this one fails:
After smarty, we have this:
In this case, the comment AND the end of line are removed, which causes that next line goes up, and in this example, comments the alert. The source code is:
|
You should probably escape any JavaScript code in your Smarty templates with
So the JavaScript and Smarty template code doesn't get mixed up and doesn't have unexpected behaviors. I guess that removing end of lines is desired behavior of Smarty compiler so if your template has a lot of comment lines then the final compiled output would not contain just empty lines. |
I agree, but the behaviour is different than in previus smarty versions, and potentially backwards incompatible, like in this case. I found it because some script started to fail in one of our pages. Now we have to check all templates, and check for any tag like this. And I'm not sure this doesn't happen with other smarty functions, besides {**}. This is not acceptable in a minor version, which everyone expects fully compatible. |
I did a PR fixing this. With this change, the output generated with smarty is exactly the same than in older versions, and the error I reported doesn't happen anymore. You've the last word about accepting it, but I think is important that minor versions maintain backwards compatibility and doesn't broke anything. |
@christiandavilakoobin thank you for your effort. The |
@wisskid We were running Smarty 3.1.29. |
@christiandavilakoobin I completely agree with you on minor version maintaining BC. However, 3.1.29 is from 2015. The change may have been introduced in 2017 or 2018. If we change it back, we'll break compatibility too. I think it's for the best to just keep it as it is now. |
If there is any "?>" in the template file, smarty is removing the end of line after the closing tag, even when isn't their own. i.e:
is changed to:
The text was updated successfully, but these errors were encountered: