You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a PrefixRegistry as the single source of truth for recognized component tag prefixes (x-, x:, flux: by default), replacing two duplicated hardcoded tables in Tokenizer and ComponentNode.
Exposes Blaze::registerPrefix(string $prefix, string $namespace = '', string $slotPrefix = 'x-slot') so consuming apps/packages can register their own tag prefixes (e.g. Blaze::registerPrefix('prefix:', namespace: 'prefix::') to recognize <prefix:icon>), mirroring how flux: already works.
ComponentNode no longer needs its own prefix→namespace lookup table: the Parser now threads the token's namespace straight through, so stripping the namespace back off for HTML fallback rendering is a plain str_starts_with/substr check.
Test plan
vendor/bin/pest — full suite passes (307 passed, 6 skipped pre-existing)
New tests/Parser/PrefixRegistryTest.php covering defaults, registration, and overwrite behavior
New/updated tests in TokenizerTest.php and ParserTest.php for a custom registered prefix
End-to-end test in BlazeManagerTest.php registering a namespace via Blade::anonymousComponentNamespace + Blaze::registerPrefix() and confirming the component compiles/inlines like a built-in prefix
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 14.93s total
To run a specific benchmark, comment /benchmark <name> attributes, aware, class, default, forwarding, merge, named-slots, no-attributes, slot, compilation
Hi @ricardogobbosouza, thanks for contributing! Would you mind sharing the use case for this? Custom namespaces are already supported in both Laravel an Blaze with <x-namespace::.
Hi @ricardogobbosouza, thanks for contributing! Would you mind sharing the use case for this? Custom namespaces are already supported in both Laravel an Blaze with <x-namespace::.
If a library like Flux is present, we cannot take advantage of Blaze.
For instance, <ui:text> is not recognized by Blaze; it only identifies the component when we use <x-ui::text>.
With this PR, we can add support for the ui: prefix, allowing the use of components like <ui:text> and, consequently, enabling the use of Blaze with libraries that adopt this pattern.
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
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.
Summary
PrefixRegistryas the single source of truth for recognized component tag prefixes (x-,x:,flux:by default), replacing two duplicated hardcoded tables inTokenizerandComponentNode.Blaze::registerPrefix(string $prefix, string $namespace = '', string $slotPrefix = 'x-slot')so consuming apps/packages can register their own tag prefixes (e.g.Blaze::registerPrefix('prefix:', namespace: 'prefix::')to recognize<prefix:icon>), mirroring howflux:already works.ComponentNodeno longer needs its own prefix→namespace lookup table: theParsernow threads the token'snamespacestraight through, so stripping the namespace back off for HTML fallback rendering is a plainstr_starts_with/substrcheck.Test plan
vendor/bin/pest— full suite passes (307 passed, 6 skipped pre-existing)tests/Parser/PrefixRegistryTest.phpcovering defaults, registration, and overwrite behaviorTokenizerTest.phpandParserTest.phpfor a custom registered prefixBlazeManagerTest.phpregistering a namespace viaBlade::anonymousComponentNamespace+Blaze::registerPrefix()and confirming the component compiles/inlines like a built-in prefix