class ComponentTagCompiler

Constants

protected BOUND_ATTRIBUTES_CONTEXT_KEY

The "bind:" attributes that have been compiled for the current component.

Properties

protected BladeCompiler $blade

The Blade compiler instance.

protected string $namespace

The application namespace.

Methods

__construct(array $aliases = [], array $namespaces = [], BladeCompiler|null $blade = null)

Create a new component tag compiler.

string
compile(string $value)

Compile the component and slot tags within the given string.

string
compileTags(string $value)

Compile the tags within the given string.

string
compileOpeningTags(string $value)

Compile the opening tags within the given string.

void
clearBoundAttributes()

Clear the bound attributes for the current component.

void
setBoundAttribute(mixed $attribute)

Set a bound attribute for the current component.

array
getBoundAttributes()

Get the bound attributes for the current component.

string
compileSelfClosingTags(string $value)

Compile the self-closing tags within the given string.

string
componentString(string $component, array $attributes)

Compile the Blade component string for the given component and attributes.

string
componentClass(string $component)

Get the component class for a given component alias.

string|null
guessAnonymousComponentUsingPaths(Factory $viewFactory, string $component)

Attempt to find an anonymous component using the registered anonymous component paths.

string|null
guessAnonymousComponentUsingNamespaces(Factory $viewFactory, string $component)

Attempt to find an anonymous component using the registered anonymous component namespaces.

string|null
findClassByComponent(string $component)

Find the class for the given component using the registered namespaces.

string
guessClassName(string $component)

Guess the class name for the given component.

string
getNamespace()

No description

string
formatClassName(string $component)

Format the class name for the given component.

string
guessViewName(string $name, string $prefix = 'components.')

Guess the view name for the given component.

array
partitionDataAndAttributes(string $class, array $attributes)

Partition the data and extra attributes from the given array of attributes.

string
compileClosingTags(string $value)

Compile the closing tags within the given string.

string
compileSlots(string $value)

Compile the slot tags within the given string.

array
getAttributesFromAttributeString(string $attributeString)

Get an array of attributes from the given attribute string.

string
parseShortAttributeSyntax(string $value)

Parses a short attribute syntax like :$foo into a fully-qualified syntax like :foo="$foo".

string
parseAttributeBag(string $attributeString)

Parse the attribute bag in a given attribute string into its fully-qualified syntax.

string
parseComponentTagClassStatements(string $attributeString)

Parse @class statements in a given attribute string into their fully-qualified syntax.

string
parseComponentTagStyleStatements(string $attributeString)

Parse @style statements in a given attribute string into their fully-qualified syntax.

string
parseBindAttributes(string $attributeString)

Parse the "bind" attributes in a given attribute string into their fully-qualified syntax.

string
compileAttributeEchos(string $attributeString)

Compile any Blade echo statements that are present in the attribute string.

string
escapeSingleQuotesOutsideOfPhpBlocks(string $value)

Escape the single quotes in the given string that are outside of PHP blocks.

string
attributesToString(array $attributes, bool $escapeBound = true)

Convert an array of attributes to a string.

string
stripQuotes(string $value)

Strip any quotes from the given string.

Details

at line 40
__construct(array $aliases = [], array $namespaces = [], BladeCompiler|null $blade = null)

Create a new component tag compiler.

Parameters

array $aliases
array $namespaces
BladeCompiler|null $blade

at line 51
string compile(string $value)

Compile the component and slot tags within the given string.

Parameters

string $value

Return Value

string

at line 63
string compileTags(string $value)

Compile the tags within the given string.

Parameters

string $value

Return Value

string

Exceptions

InvalidArgumentException

at line 75
protected string compileOpeningTags(string $value)

Compile the opening tags within the given string.

Parameters

string $value

Return Value

string

Exceptions

InvalidArgumentException

at line 134
protected void clearBoundAttributes()

Clear the bound attributes for the current component.

Return Value

void

at line 143
protected void setBoundAttribute(mixed $attribute)

Set a bound attribute for the current component.

Parameters

mixed $attribute

Return Value

void

at line 153
protected array getBoundAttributes()

Get the bound attributes for the current component.

Return Value

array

at line 163
protected string compileSelfClosingTags(string $value)

Compile the self-closing tags within the given string.

Parameters

string $value

Return Value

string

Exceptions

InvalidArgumentException

at line 224
protected string componentString(string $component, array $attributes)

Compile the Blade component string for the given component and attributes.

Parameters

string $component
array $attributes

Return Value

string

Exceptions

InvalidArgumentException

at line 266
string componentClass(string $component)

Get the component class for a given component alias.

Parameters

string $component

Return Value

string

Exceptions

InvalidArgumentException

at line 313
protected string|null guessAnonymousComponentUsingPaths(Factory $viewFactory, string $component)

Attempt to find an anonymous component using the registered anonymous component paths.

Parameters

Factory $viewFactory
string $component

Return Value

string|null

at line 346
protected string|null guessAnonymousComponentUsingNamespaces(Factory $viewFactory, string $component)

Attempt to find an anonymous component using the registered anonymous component namespaces.

Parameters

Factory $viewFactory
string $component

Return Value

string|null

at line 379
string|null findClassByComponent(string $component)

Find the class for the given component using the registered namespaces.

Parameters

string $component

Return Value

string|null

at line 399
string guessClassName(string $component)

Guess the class name for the given component.

Parameters

string $component

Return Value

string

at line 408
protected string getNamespace()

No description

Return Value

string

at line 422
string formatClassName(string $component)

Format the class name for the given component.

Parameters

string $component

Return Value

string

at line 434
string guessViewName(string $name, string $prefix = 'components.')

Guess the view name for the given component.

Parameters

string $name
string $prefix

Return Value

string

at line 452
array partitionDataAndAttributes(string $class, array $attributes)

Partition the data and extra attributes from the given array of attributes.

Parameters

string $class
array $attributes

Return Value

array

at line 475
protected string compileClosingTags(string $value)

Compile the closing tags within the given string.

Parameters

string $value

Return Value

string

at line 483
string compileSlots(string $value)

Compile the slot tags within the given string.

Parameters

string $value

Return Value

string

at line 561
protected array getAttributesFromAttributeString(string $attributeString)

Get an array of attributes from the given attribute string.

Parameters

string $attributeString

Return Value

array

at line 620
protected string parseShortAttributeSyntax(string $value)

Parses a short attribute syntax like :$foo into a fully-qualified syntax like :foo="$foo".

Parameters

string $value

Return Value

string

at line 632
protected string parseAttributeBag(string $attributeString)

Parse the attribute bag in a given attribute string into its fully-qualified syntax.

Parameters

string $attributeString

Return Value

string

at line 645
protected string parseComponentTagClassStatements(string $attributeString)

Parse @class statements in a given attribute string into their fully-qualified syntax.

Parameters

string $attributeString

Return Value

string

at line 665
protected string parseComponentTagStyleStatements(string $attributeString)

Parse @style statements in a given attribute string into their fully-qualified syntax.

Parameters

string $attributeString

Return Value

string

at line 685
protected string parseBindAttributes(string $attributeString)

Parse the "bind" attributes in a given attribute string into their fully-qualified syntax.

Parameters

string $attributeString

Return Value

string

at line 702
protected string compileAttributeEchos(string $attributeString)

Compile any Blade echo statements that are present in the attribute string.

These echo statements need to be converted to string concatenation statements.

Parameters

string $attributeString

Return Value

string

at line 715
protected string escapeSingleQuotesOutsideOfPhpBlocks(string $value)

Escape the single quotes in the given string that are outside of PHP blocks.

Parameters

string $value

Return Value

string

at line 731
protected string attributesToString(array $attributes, bool $escapeBound = true)

Convert an array of attributes to a string.

Parameters

array $attributes
bool $escapeBound

Return Value

string

at line 747
string stripQuotes(string $value)

Strip any quotes from the given string.

Parameters

string $value

Return Value

string