IntoValue

Derive Macro IntoValue 

Source
#[derive(IntoValue)]
Expand description

Derive macro for converting a struct to a Typst value.

All structs that will be passed to Typst templates (directly or nested) must derive this.

§Example

use typst_bake::{IntoValue, IntoDict};

#[derive(IntoValue, IntoDict)]  // Top-level: both macros
struct Inputs {
    title: String,
    products: Vec<Product>,
}

#[derive(IntoValue)]  // Nested: IntoValue only
struct Product {
    name: String,
    price: f64,
}

In Typst templates, nested structs are accessed as dictionaries:

#for product in inputs.products [
  - #product.name: $#product.price
]