Learn

Create a Template Schema

Author a Cuddler Template Schema that defines how validated data should be rendered without weakening data validation.

Tutorial path

How a Template Schema should be authored

The Template Schema starts from validated data and then describes how that data should be arranged for rendering.

1Start from the data shape

Do not invent the template contract from the desired layout alone.

2Map sections and bindings

Tie headings, repeated blocks, and structure to stable data paths.

3Keep template rules local

Describe rendering behavior without trying to redefine the data contract.

4Validate the template on its own

Check the render contract after the data contract is already sound.

Presentation is a separate contract, not an override for bad data.

A Template Schema defines presentation, not truth. It should describe how the already-validated data is arranged into the final document, while leaving the data contract intact.

  1. Start from the validated data shape, not from the desired page layout.
  2. Map sections, headings, and repeated blocks to stable data paths.
  3. Keep template-specific instructions focused on rendering behavior.
  4. Validate the template on its own after the data contract is already sound.

Keep the boundary clean

  • Data validation comes first.
  • Template validation comes second.
  • Template rules should not override a bad or missing data contract.
  • Rendered output should stay predictable once both inputs validate.

Good template habits

  • Use explicit field references instead of broad assumptions.
  • Keep repeated sections tied to arrays with stable item shapes.
  • Write safe rendering behavior as the default, not the exception.