smarty-php / smarty

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

use 'short echo tag' in generated output..? #894

Open davidbuzz opened 1 year ago

davidbuzz commented 1 year ago

a lot of the generated php in the cache/php folder looks like this: <?php echo 'xxxxx'; ?> when it could be made more readable, and shorter by being like this: <?='xxxxx'?> ... which is much shorter, and easier to read, and also makes the cached files a bunch shorter and so less disk acceses etc. 'short echo tag', ie <?= is enabled-by-default on all php since 5.4, and isn't related to then 'short open tag' any more.

I think it would be beneficial to move to to using htese shorter tags. .. or at least have it as an option when configuring smarty to decide what tags to use . ? https://wiki.php.net/rfc/deprecate_php_short_tags_v2

scottchiefbaker commented 1 year ago

This would only work IF short tags were enabled at the PHP level. Most installations do not enable this. Also considering they've attempted to deprecated this twice now, I'm not in a hurry to start supporting it.

wisskid commented 1 year ago

I believe the short echo tag is always available regardless of settings, since php 5.4.

That said, the upside of this change is very small. The generated php code isn't meant for easy reading (yet) and contains a lot more php code than just echo statements. Switching to the short echo tag won't do a lot to make it more readable.

In fact, it even makes it impossible to run adjecent blocks of php code together.

davidbuzz commented 1 year ago
lkppo commented 1 year ago

These are penny-pinching savings.