//! AST types for el-ui component files. /// A parsed component definition. #[derive(Debug, Clone)] pub struct Component { pub name: String, pub props: Vec, pub state: Vec, pub methods: Vec, pub template: Template, } /// A prop declaration inside `props { ... }`. #[derive(Debug, Clone)] pub struct PropDef { pub name: String, pub type_name: String, pub default: Option, } /// A state declaration inside `state { ... }`. #[derive(Debug, Clone)] pub struct StateDef { pub name: String, pub type_name: String, pub initial: String, } /// A method defined with `fn` inside the component body. #[derive(Debug, Clone)] pub struct Method { pub name: String, pub params: Vec<(String, String)>, // (name, type) pub return_type: String, pub body: String, // raw source text of the body (we pass through verbatim) } /// The template block. #[derive(Debug, Clone)] pub struct Template { pub nodes: Vec, } /// A node within the template tree. #[derive(Debug, Clone)] pub enum TemplateNode { /// A plain HTML element: `
...
` Element { tag: String, attrs: Vec, children: Vec, }, /// A component usage (uppercase first letter): `` Component { name: String, props: Vec, }, /// Literal text content. Text(String), /// An interpolated expression: `{count}` Interpolation(String), /// Conditional: `{#if cond}...{/if}` or `{#if cond}...{:else}...{/if}` If { condition: String, then: Vec, else_: Option>, }, /// List rendering: `{#each items as item}...{/each}` Each { items: String, item_name: String, children: Vec, }, /// Semantic activation query: `{#activate "query" as results}...{/activate}` Activate { query: String, result_name: String, children: Vec, }, } /// An attribute on a template element. #[derive(Debug, Clone)] pub enum Attr { /// `class="btn"` — static string value Static { name: String, value: String }, /// `class={expr}` — dynamic expression Dynamic { name: String, expr: String }, /// `on:click={handler}` — event handler EventHandler { event: String, handler: String }, /// `disabled={boolExpr}` — boolean attribute BoolAttr { name: String, expr: String }, }