pub struct Template {
pub nodes: Vec<Node>,
}Expand description
A parsed template AST. Created by parsing template syntax via syn::parse2::<Template>(tokens).
Fields§
§nodes: Vec<Node>Implementations§
Source§impl Template
impl Template
Sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
Returns the source span of the first node, or Span::call_site() if empty.
Sourcepub fn to_display_stream(
&self,
injections: &[(String, TokenStream)],
) -> TokenStream
pub fn to_display_stream( &self, injections: &[(String, TokenStream)], ) -> TokenStream
Returns a flat TokenStream representing the template’s output pattern.
Unlike to_token_stream, which produces builder code,
this produces the structural output: literal tokens pass through, interpolations
emit their expression or a substituted value, and control flow emits its body structure.
injections is a slice of (key, tokens) pairs. When an interpolation expression
matches a key, the corresponding tokens are substituted. Unmatched interpolations
render as {{ expr }} placeholders.
Sourcepub fn to_token_stream(&self) -> TokenStream
pub fn to_token_stream(&self) -> TokenStream
Expands the template into a TokenStream without an Input binding.
Sourcepub fn render(&self, input: &Input) -> TokenStream
pub fn render(&self, input: &Input) -> TokenStream
Expands the template with the given Input bound as input in the generated code.