pub enum Node {
Text(String),
Echo {
expr: Expr,
escaped: bool,
},
If {
branches: Vec<Branch>,
otherwise: Option<Vec<Node>>,
},
Foreach {
subject: Expr,
binding: String,
body: Vec<Node>,
},
Yield {
section: String,
default: Option<Expr>,
},
Include(TemplateRef),
Lang {
key: String,
replacements: Vec<(String, Expr)>,
},
Route {
name: String,
params: Vec<(String, Expr)>,
},
}Expand description
One renderable piece of a template.
Variants§
Text(String)
Literal markup.
Echo
{{ expr }} when escaped, {!! expr !!} when not.
If
@if / @elseif / @else: the first branch whose condition is truthy
wins, otherwise otherwise runs if there is one.
Foreach
@foreach(subject as binding).
Yield
@yield("name"), with the optional fallback from @yield("name", expr).
Include(TemplateRef)
@include("partial").
Lang
@lang("auth.sign_in"), and @lang("greeting", "name", user.name) when
the phrase has placeholders.
The key is resolved when the page is rendered, never when the template
is parsed. A parsed template is cached and shared between requests, so
baking one language’s words into it would serve those words to
everybody — see Engine::translator.
Route
@route("users.show", "id", user.id) — the path of a named route.
Trait Implementations§
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more