smarty-php / smarty-php/smarty

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

Open
#1,010 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
2.3k
Forks
709
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Smarty v5 documentation page for $smarty.template and reproduce the reported result with a template such as components/topmenubar.html on version 5.10.0. Compare the v3/v4 and v5 outputs, then determine whether the documented behavior or the implementation should change; done means the behavior and documentation agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.