smarty-php / smarty-php/smarty
Suggestion: {namspace} compile tag
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 709
- PR merge metrics
- No merged PRs in 30d
Description
I experience quite frequently that class constants or enums have to be used in templates, e.g. in but not limited to if-conditions. These constants are typically located in namespaces.
Smarty templates for now reside in the root namespace, requiring to use absolute paths. Quite often all constants are from the same namespace, so that a {namespace} tag could make the template easier to handle, kind of this:
{namespace Foo\Bar\Baz}
{if $item->getSomeProperty() === ItemProperty::SomeValue}
<p>this</p>
{elseif $item->getSomeProperty() === ItemProperty::SomeOtherValue}
<p>that</p>
{elseif ...}
{else}
<p class="warning">some property is not valid</p>
{/if}
{/namespace}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by locating Smarty’s template compilation and tag-handling paths, then determine how the proposed {namespace} block should affect constant resolution. Done means the syntax and its behavior are defined and validated against the constant comparisons shown in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100