Skip to main content
Define and version reusable HTML templates as components for consistent UI across ensembles.

Overview

Template components enable you to:
  • Reuse templates across multiple HTML and Page operations
  • Version templates with semantic versioning for consistency
  • A/B test different template versions
  • Organize layouts and components separately
  • Deploy templates independently from code
  • Cache at the edge for fast loading (~0.1ms)

Quick Start

1. Create a Template Component

Create an HTML template file with your preferred template engine:

2. Add to Edgit

3. Reference in Your Ensemble

URI Format and Versioning

All template components use the standardized URI format:
Format breakdown:
  • template:// - Protocol identifier for template components
  • {path} - Logical path to the template (e.g., layouts/main, components/header)
  • [@{version}] - Optional version identifier (defaults to @latest)
Version format:
  • @latest - Always uses the most recent version
  • @v1 - Uses latest patch of major version (v1.x.x)
  • @v1.0.0 - Specific semantic version (immutable)
  • @prod - Custom tag for production versions
  • @staging - Custom tag for staging versions

Example URIs

Template Engines

Templates support multiple rendering engines:

Handlebars (Default)

Full featured with helpers, partials, and blocks:

Liquid

Django/Jekyll-style templates:

Simple

Lightweight variable substitution:

MJML

Email templates with responsive design:

How to Reference in Ensembles

There are three ways to reference templates in your ensembles: Use the template:// URI format to reference versioned template components as layouts or partials:

2. Partial Template Format

Use {{> template://path@version}} to embed template partials:

3. Inline Template

For simple operations or during development, use inline templates directly. Option A: Structured template with engine:
Option B: Raw HTML with interpolation:

Using Templates in Operations

With Partial Components

HTML Operation with Template

Email with Template

Layouts and Partials

Layouts

Layouts wrap content with common structure (header, footer, etc.):
The {{{content}}} variable in the layout receives the rendered template.

Partials

Partials are reusable components included in templates:
Partials automatically receive the same data context as the parent template.

Caching and Performance

Template components are automatically cached for 1 hour (3600 seconds) after first load.

Default Caching

Performance:
  • First load: Fetched from KV (~5-10ms)
  • Subsequent loads: Served from edge cache (~0.1ms)
  • Cache per version: Each version cached independently

Custom Cache TTL

Bypass Cache

Best Practices

1. Version Your Templates

Use semantic versioning to track changes:

2. Use Production Tags

Create stable version tags for production ensembles:

3. Organize by Purpose

Use path hierarchies for organization:

4. Long Cache for Stable Templates

5. Include Metadata

Add comments to templates for documentation:

6. Test Before Promoting

Component Catalog

Conductor includes a catalog of production-ready templates:

Deploy Catalog Templates

See the catalog README for complete documentation.

Versioning Strategy

Development Workflow

Rollback Strategy

Using ctx API in Agents

When building custom agents with TypeScript handlers, you can access and render templates through the ctx API:

ctx.templates.render(name, vars)

Render an HTML template with variables:

Dynamic Template Selection

Rendering with Layout

Multi-Template Composition

Template Rendering with Error Handling

Conditional Template Rendering

Troubleshooting

Template Not Found

Error: Component not found: template://layouts/main@v1.0.0 Solution:
  1. Check template exists: edgit list templates
  2. Check version: edgit tag list main-layout
  3. Verify deployment: edgit tag show main-layout@v1.0.0

Template Rendering Errors

Issue: Variables not being replaced or syntax errors Solutions:
  1. Check engine matches template syntax (handlebars vs liquid vs simple)
  2. Verify all required variables are provided in data
  3. Check template syntax is valid for the chosen engine
  4. Test template locally before deploying

Partial Not Loading

Issue: {{> template://components/header}} not rendering Solution: Ensure the partial is:
  1. Deployed to KV with correct path
  2. Using correct URI format
  3. Compatible with the template engine (handlebars supports partials)

Cache Issues

Issue: Updated template not being used Solution: Invalidate cache or set cache.bypass: true

Next Steps

HTML Operation

Generate HTML with templates

PDF Operation

Generate PDFs from templates

Email Operation

Send emails with templates

Edgit Versioning

Version control for components