Skip to main content
The Hello World sample is the simplest TemplateMark template, demonstrating basic variable substitution. It’s perfect for getting started and understanding the fundamentals.

Complete Example

Model

The model defines a simple concept with a single name property:
namespace [email protected]

@template
concept HelloWorld {
    o String name
}
Key Points:
  • namespace [email protected] - Defines the namespace and version
  • @template - Decorator marking this as a template concept
  • o String name - A required string property called name

Template

The template uses markdown with a variable placeholder:
> The one, the only...

### Hello {{name}}!
Key Points:
  • {{name}} - Variable placeholder that gets replaced with the actual name
  • Uses standard markdown syntax (blockquote > and heading ###)
  • Clean and simple formatting

Data

The data object provides the value for the template:
{
  "$class": "[email protected]",
  "name": "John Doe"
}
Key Points:
  • $class - Fully-qualified type name matching the model
  • name - The value that will replace {{name}} in the template

Generated Output

When rendered, this template produces:
The one, the only…

Hello John Doe!

Usage

Here’s how to use this sample in your code:
import { TemplateMarkTransformer } from '@accordproject/markdown-template';

const MODEL = `namespace [email protected]

@template
concept HelloWorld {
    o String name
}`;

const TEMPLATE = `> The one, the only...

### Hello {{name}}!
`;

const DATA = {
  "$class": "[email protected]",
  "name": "John Doe"
};

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

console.log(result);

Try It Yourself

Experiment with different values:
{
  "$class": "[email protected]",
  "name": "Alice"
}
Output:
The one, the only…

Hello Alice!

{
  "$class": "[email protected]",
  "name": "Dr. Sarah Johnson"
}
Output:
The one, the only…

Hello Dr. Sarah Johnson!

Extending the Sample

You can extend this basic sample by:
  1. Adding more properties:
@template
concept HelloWorld {
    o String name
    o String greeting optional
}
  1. Using the properties in the template:
> The one, the only...

### {{greeting}} {{name}}!
  1. Providing the data:
{
  "$class": "[email protected]",
  "name": "John Doe",
  "greeting": "Welcome"
}

Formula Sample

Add dynamic calculations to your templates

Employment Offer

See a more complex real-world example

Next Steps

Build docs developers (and LLMs) love