Expand description
Blade-inspired template parsing for *.blade.xr files.
This crate is pure text parsing plus a small runtime (View, escape) -
no syn/proc-macro2 dependency. Turning the parsed Node tree
into actual Rust code lives in larust-macros’ view! macro, since
that’s the part that needs the proc-macro toolchain and file-tracking
plumbing that’s local to a specific crate compilation.
Modules§
- push_
registry - A small request-scoped runtime registry that lets
@pushcontent cross a boundary@stack/@push’s normal compile-time resolution can’t see across - specifically a<wire:...>mount point, which is a genuinely separateview!(...)call with no shared AST (seedocs/GOTCHAS.md’s@push/@stackentry for the full picture).
Structs§
- Global
Entry - A parsed
.blade.xrtemplate, before layout resolution. - Parse
Error - A template parsing/resolution error. Deliberately just a message -
larust-macrosis the one place that can turn this into a proper spannedsyn::Error, and the file/template context is usually already in the message by the time it gets there. - View
- A rendered template. What
view!(...)(inlarust-macros) produces.
Enums§
Functions§
- escape
- HTML-escapes a string for safe interpolation (
{{ }}, not{!! !!}). - js
@js($expr)’s JS-safe (not HTML-escaped) serialization - drops aSerializevalue into inline JavaScript as aJSON.parse('...')call, mirroring Laravel’sIlluminate\Support\Js::from()two-layer mechanism faithfully:- parse
- resolve
- Resolves
@extends/@section/@yield/@push/@stackcomposition into a single, flat node list ready for codegen. - resolve_
with_ context - Same as
resolve, but also returns the whole-tree@push/@globalscollections it gathered along the way - needed bylarust-macros, which loads and codegens each<resource:...>tag’s own named template separately from this call (seeNode::Resource’s own doc comment inast.rs), and must applysubstitute_stacks/substitute_globalsto that freshly-loaded content itself using these same maps - otherwise a@push/@stackpair split across a resource-tag boundary (the single most common shape in practice: a sharedcomponents.layouts.appproviding@stack('head'), included via<resource:...>from every page, with pages pushing their own per-page<link>/<meta>tags into it) would never connect -@stack('head')sitting inside that separately-loaded layout file is invisible to this call’s ownsubstitute_stacks, which only ever walks the nodes passed in asnodeshere. - substitute_
globals - Mirrors
substitute_stacksbelow, but for@global: walks the fully resolved tree, replacingNode::Global { name, fallback }with a realNode::Interpolatesourced from whichever@globalsblock (anywhere in the chain) provided that name, falling back tofallbackif none did, or nothing if there’s no fallback either - same “unset becomes empty” convention as an unset@stack. Apersist-flagged entry substitutes toNode::PersistGlobalinstead - its value isn’t known until request time, so it can’t collapse to a literalInterpolatethe way every other entry does; see that node’s own doc comment. - substitute_
stacks - Mirrors
substitute_yieldsbelow, but for@stack- kept as a separate pass (run once, after the entire@extendschain is already section/yield-resolved) rather than folded intosubstitute_yieldsitself, sincepushesneeds contributions from every level of the chain before any@stackcan be substituted correctly (seeresolve_inner’s doc comment oncollect_pushes).