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

Smarty v5 $smarty.template behavior doesn't match v5 documentation (it now includes a type and directory part) #1010

Open
cmanley opened this issue May 5, 2024 · 0 comments

Comments

@cmanley
Copy link

cmanley commented May 5, 2024

Since version Smarty v5, the $smarty.template variable returns the type.path/file name of the current template, despite the documentation claiming that it "Returns the name of the current template being processed (without the directory)".
https://smarty-php.github.io/smarty/stable/designers/language-variables/language-variables-smarty/#smartytemplate

For a given template name e.g. components/topmenubar.html
This is what I got with v3 and v4:
topmenubar.html
and this is what I get in 5.10.0:
file:components/topmenubar.html

So the behavior doesn't match the documentation.

Background info:
I use the full template path and file name to pass to a translation modifier by placing this at the top of each template (|basename is added for v5):
[% $template = "`$smarty.current_dir`/`$smarty.template|basename`" scope="root" %]
and then translating all template strings for the current template this way:
[% 'Log off'|xlat:$template|escape %]
If there were an easier way to get the current template path + file from which a modifier is being called, then I'd use that.

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

1 participant