smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.26k stars 711 forks source link

{getImageDimensions image = $tmpImages[0]} error #1077

Open criocere opened 1 week ago

criocere commented 1 week ago

Still trying to migrate from v4 to v5... I try also to use extensions for tags and modifiers

This line is ok in smarty v4 {getImageDimensions image = $tmpImages[0]}

But in smarty v5 I get Got error 'PHP message: PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:zzzzPage.tpl" on line 235 "{getImageDimensions image = $tmpImages[0]}" unknown tag 'getImageDimensions'

If I modify my line like this (adding a blank after the first bracket), it becomes ok { getImageDimensions image = $tmpImages[0]}

elgarfo commented 1 week ago

does the code work for you when adding the space?

i have somewhat similar problem that a registered tag compiler is not executed. in my case, adding the space before the tagname prevents the error, but the code does not get executed and smarty just outputs the curly braces and its contents as string.

EDIT: might be related to #907 and #910. in my case it was a custom tag compiler that was registered as "CustomTag". i was unable to use it with "{CustomTag}" in a template. got it working again after changing the registerPlugin call to "customtag" instead. FWIW: i am migrating a codebase from smarty 3.

criocere commented 1 week ago

Yes I think you are right. Because I have errors on all my plugins when I try to use the extension. I don't see the result.

I described my problem completely here https://github.com/smarty-php/smarty/discussions/1072

I am blocked in my migration in v5 to convert all my plugins and modifiers (more than 50) in an extension. I'm quite sure to follow the doc but that doesn't work. If I use registerPlugin, everything is ok but I don't like this solution, it seems not very performant as I have more than 50 call to registerPlugin!!

Any idea?