smarty-php / smarty-php/smarty

Suggestion: {namspace} compile tag

Open
#1,008 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

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.