nori/codegen/templates

Template-based code generation using the handles library.

Stores default templates and provides IR-to-context converters for TypeScript code generators.

Types

pub type TsConfig {
  TsConfig(
    use_exports: Bool,
    use_interfaces: Bool,
    readonly_properties: Bool,
  )
}

Constructors

  • TsConfig(
      use_exports: Bool,
      use_interfaces: Bool,
      readonly_properties: Bool,
    )

Values

pub const default_template_dir: String

Default template directory (relative to project root)

pub fn ir_to_ts_client_context(ir: ir.CodegenIR) -> ctx.Value
pub fn ir_to_ts_react_query_context(
  ir: ir.CodegenIR,
) -> ctx.Value
pub fn ir_to_ts_swr_context(ir: ir.CodegenIR) -> ctx.Value
pub fn ir_to_ts_types_context(
  ir: ir.CodegenIR,
  config: TsConfig,
) -> ctx.Value
pub fn load_template(
  template_dir: String,
  name: String,
) -> String

Load a template from file, or fall back to the embedded default.

pub fn render(template_str: String, context: ctx.Value) -> String

Compile and run a handles template with the given context.

Templates can come from disk (user-customized .hbs files in templates/), so errors are surfaced inline in the generated output as a header comment instead of crashing. Grep generated files for nori: template error to detect failures in CI.

Search Document