Blade Parser

Blade Parser

Custom Component Tags

The document parser supports registering custom component tag prefixes. By default, the parser is configured to parse elements beginning with <x-, <x:, </x, or </x: as Blade component tags; this behavior cannot be changed.

However, we can add custom component tag prefixes using the registerCustomComponentTag or registerCustomComponentTags methods:

3use Stillat\BladeParser\Parser\DocumentParser;
5$parser = new DocumentParser;
7// Register a single custom component prefix.
10// Register multiple custom component prefixes.
12 'a', 'b', 'c',

The document parser will parse all custom component tag prefixes as if they were Blade components and provide all relevant information, such as parameters, tag names, namespaces, etc.

With our custom component tag prefixes, all of the following would be equivalent:

1<a-alert :$message />
2<b-alert :$message />
3<c-alert :$message />
4<x-alert :$message />

#Custom Component Tag Compilation

To learn how to modify the compilation behavior of custom components, please consult the article Compiling Custom Components.

Some absolutely amazing

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.