.do
Development

templates

Template library and management

templates

Template management for emails, documents, code, and content with variable substitution, versioning, and rendering engines.

Overview

The templates primitive provides a unified template system supporting multiple formats (Handlebars, Mustache, MDX) with variable interpolation, partials, and helpers.

Quick Example

import { templates } from 'sdk.do'

// Create template
const welcome = await templates.create({
  name: 'welcome-email',
  type: 'email',
  subject: 'Welcome to {{companyName}}!',
  body: `
    Hello {{userName}},

    Welcome to {{companyName}}! We're excited to have you.

    {{#if hasPromo}}
    Use code {{promoCode}} for 20% off your first order.
    {{/if}}
  `,
})

// Render template
const rendered = await templates.render('welcome-email', {
  userName: 'Alice',
  companyName: 'Acme Inc',
  hasPromo: true,
  promoCode: 'WELCOME20',
})

// Use template
await emails.send({
  to: '[email protected]',
  ...rendered,
})

Core Capabilities

  • Multiple Formats - Handlebars, Mustache, MDX, and custom engines
  • Variable Substitution - Dynamic content with data binding
  • Partials & Helpers - Reusable components and functions
  • Versioning - Track template changes over time
  • Preview & Testing - Test templates before deployment

Access Methods

SDK

TypeScript/JavaScript library for template management

await templates.create({ name: 'welcome-email', type: 'email', body: '...' })

SDK Documentation

CLI

Command-line tool for template operations

do template create welcome-email --type email --file template.hbs

CLI Documentation

API

REST/RPC endpoints for template management

curl -X POST https://api.do/v1/templates -d '{"name":"welcome-email","body":"..."}'

API Documentation

MCP

Model Context Protocol for AI-driven template operations

Create an email template named "welcome-email" with subject "Welcome to {{companyName}}!"

MCP Documentation