Skip to main content
Sample templates provide working examples that demonstrate how to use TemplateMark features in real-world scenarios. Each sample includes a complete MODEL, TEMPLATE, and DATA structure that you can use as a starting point for your own templates.

Available Samples

The following samples are available to help you get started:

Basic Samples

Hello World

A simple introduction to TemplateMark with basic variable substitution

Blank Template

Empty template to start from scratch

Business Document Samples

Employment Offer

Professional employment offer letter with salary, dates, and optional probation period

NDA

Non-Disclosure Agreement template with parties, purpose, and duration

Payment Receipt

Detailed payment receipt with VAT calculation and party information

Invitation

Event invitation with date formatting and nested address structure

Feature Demonstration Samples

Customer Order

Complex sample demonstrating clauses, lists, joins, formulas, and date handling

Formula Examples

Demonstrates inline TypeScript formulas for dynamic calculations

Formula with Now

Shows time-based calculations using the now variable

List Operations

Examples of ordered, unordered, and joined lists

Join Lists

Natural language joining of arrays with locale support

Clauses

Demonstrates clause blocks for nested object rendering

Conditional Clauses

Shows conditional rendering based on data properties

Optional Content

Handling optional fields with if/else blocks

Markdown Features

Rich markdown formatting within templates

Announcement

Product announcement template with structured content

Sample Structure

Each sample template consists of three main components:

1. MODEL

The model defines the data structure using Concerto modeling language. It specifies:
  • Namespace and version
  • Concept definitions with properties
  • Data types and constraints
  • Optional fields
  • The @template decorator on the main concept

2. TEMPLATE

The template contains:
  • Markdown-formatted content
  • Variable placeholders using {{variable}} syntax
  • Formatting expressions like {{date as "DD MMMM YYYY"}}
  • Conditional blocks with {{#if}}
  • Clauses with {{#clause}}
  • Formulas with {{% return expression %}}

3. DATA

The data object provides:
  • A $class property specifying the fully-qualified type
  • Values for all required properties
  • Optional values for optional properties
  • Nested objects for complex types

Using Samples

To use a sample template:
  1. Copy the model - Define your data structure
  2. Customize the template - Modify the markdown and variable placeholders
  3. Provide your data - Create a data object matching your model
  4. Generate output - Use the TemplateMark engine to render the template
import { TemplateMarkTransformer } from '@accordproject/markdown-template';

const transformer = new TemplateMarkTransformer();
const result = await transformer.generate({
  model: MODEL,
  template: TEMPLATE,
  data: DATA
});

Common Patterns

Across these samples, you’ll see common patterns:
  • Date Formatting: {{effectiveDate as "DD MMMM YYYY"}}
  • Number Formatting: {{doubleValue as "0,0"}}
  • Conditional Sections: {{#if probation}}...{{/if}}
  • Clauses: {{#clause address}}...{{/clause}}
  • Formulas: {{% return name.length %}}
  • Lists: {{#ulist items}}...{{/ulist}}
  • Joins: {{#join favoriteColors}}

Next Steps

Hello World Sample

Start with the simplest example

Template Syntax

Learn the complete template syntax

Data Modeling

Understand Concerto data models

API Reference

Explore the API documentation

Build docs developers (and LLMs) love