Skip to content
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

Modifier syntax changed? Spaces around | causes error #887

Closed
wxiaoguang opened this issue Jun 4, 2023 · 3 comments
Closed

Modifier syntax changed? Spaces around | causes error #887

wxiaoguang opened this issue Jun 4, 2023 · 3 comments

Comments

@wxiaoguang
Copy link
Contributor

Before it works:

{$var | string_format:"%.2f"}

But with 4.3.1, it reports error:

Syntax error in template "my.tpl" on line 33 "<td>{$var | string_format:"%.2f"} MB</td>" - Unexpected "|"

Removing the spaces then {$var|string_format:"%.2f"} works in 4.3.1.

It looks like a regression?

@wisskid
Copy link
Contributor

wisskid commented Jun 4, 2023

Do you know what the latest version is where your syntax still works? Thanks.

@wisskid
Copy link
Contributor

wisskid commented Jun 5, 2023

It's not a regression, at least not a recent one. I tested it against 3.1.46 with the same result. You're probably coming from Smarty v2? The v2 > v3 upgrade guide doesn't specifically mention your codestyle, but it does mention that Smarty 3 has a new syntax, which is stricter. It also mentions whitespace from being important now. Since v3 has been out over a decade now, we will stick to the v3 syntax.

@wisskid wisskid closed this as completed Jun 5, 2023
@wxiaoguang
Copy link
Contributor Author

Thank you for your help. I think you are right. The project is very old and was using Smarty v2 long time ago. It has been running with Smarty v3/v4 for long time. Maybe the template with the old syntax is seldom used, so I didn't notice the error until today.

I will do more checks, thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants