Skip to content

[6.x] Support for namespaced tags#14800

Open
marcorieser wants to merge 4 commits into
statamic:6.xfrom
marcorieser:feat/namespaced-tags
Open

[6.x] Support for namespaced tags#14800
marcorieser wants to merge 4 commits into
statamic:6.xfrom
marcorieser:feat/namespaced-tags

Conversation

@marcorieser

@marcorieser marcorieser commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This PR adds opt-in namespace support for tags, analogous to how views are namespaced (vendor::view):

{{ juicebox::my_tag:method }}

Why

Tag handles are currently global. Two addons registering a tag with the same handle silently collide (last one wins), and there's no way to explicitly address a specific addon's tag.

Usage

Addons opt in by setting a property on their service provider:

class ServiceProvider extends AddonServiceProvider {
    protected $tagNamespace = 'juicebox';
}

When set, the addon's tags (and their aliases) are registered only under the namespace — {{ juicebox::my_tag }} — and no longer under their bare handles. Since the property defaults to null, existing addons are unaffected.

The underlying mechanism is generic: RegistersItself::register() now accepts an optional namespace, so any tag class can be registered namespaced manually:

MyTag::register('juicebox');

Namespaced tags work across all three surfaces:

  • Antlers: {{ juicebox::my_tag:method }}, including paired tags, self-closing tags, and interpolations in conditions
  • Blade components: <s:juicebox::my_tag:method />
  • Fluent: Statamic::tag('juicebox::my_tag:method')

Notes

  • Non-breaking: behavior only changes when an addon explicitly sets $tagNamespace.

@marcorieser marcorieser changed the title Support for namepaced tags [6.x] Support for namepaced tags Jun 10, 2026
@marcorieser marcorieser changed the title [6.x] Support for namepaced tags [6.x] Support for namespaced tags Jun 10, 2026
@marcorieser marcorieser marked this pull request as ready for review June 10, 2026 10:38
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

Successfully merging this pull request may close these issues.

1 participant