[6.x] Support for namespaced tags#14800
Open
marcorieser wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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:Namespaced tags work across all three surfaces:
{{ juicebox::my_tag:method }}, including paired tags, self-closing tags, and interpolations in conditions<s:juicebox::my_tag:method />Statamic::tag('juicebox::my_tag:method')Notes
$tagNamespace.