Expand description
Turn a component’s .livewire source into the Jinja template the engine renders.
A component file is Blade-flavoured HTML: <livewire:…> tags, @livewire,
@this, @entangle, @assets, @script, @teleport, @persist,
@island, and the three asset helpers. This module rewrites exactly those
constructs and copies every other byte. Jinja tags ({{ … }}, {% … %},
{# … #}) are left untouched, and an @word it does not know stays where
it is, so Blade control flow such as @if survives verbatim.
Two framework transforms are injected on request:
- Morph markers —
<!--[if BLOCK]><![endif]-->before an opening{% if %}/{% for %}and<!--[if ENDBLOCK]><![endif]-->after its closing tag, matchingSupportMorphAwareBladeCompilationbyte for byte. A block inside an HTML tag (a conditional class, for example) gets none: the browser’s morph would otherwise see a marker inside an attribute. - Smart wire keys — a nested component with no
wire:keythat sits inside a loop receives a deterministic key built from the template identity, the component’s position in the source, and each enclosingloop.index0.
@island … @endisland compiles to the <!--[if FRAGMENT:…]><![endif]-->
marker pair that js/fragment.js and js/island.js parse, carrying type,
name, token, and mode as key=value pairs.
Compilation never fails: truncated input, an unclosed tag, or an unbalanced directive is copied as it stands.
Structs§
- Compile
Options - What to inject while compiling.
- Template
Identity - Where a component’s source came from, which keys its nested components deterministically.
Functions§
- compile
- Translates the component source into the Jinja the engine compiles.