In this module, you’ll create a TemplateMark template that uses the Concerto model you defined in Module 1. TemplateMark allows you to create dynamic templates with variables that get replaced with actual data at runtime.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/accordproject/template-playground/llms.txt
Use this file to discover all available pages before exploring further.
Learn more about TemplateMark in the TemplateMark specification
What you’ll build
You’ll create a simple template that displays “Hello” followed by a dynamic name variable. This template will use thename property from your HelloWorld model.
Creating your template
Open the TemplateMark editor and follow along:Write the basic template
Create a template with plain text and a variable placeholder. Variables in TemplateMark are enclosed in double curly braces This template consists of:
{{ and }}.- Plain text:
"Hello"and"." - A variable:
{{name}}that will be replaced with actual data
Understanding TemplateMark syntax
TemplateMark uses a simple syntax for dynamic content:{{variableName}}- Inserts the value of a variable- Variables must match property names in your Concerto model
- You can combine variables with any markdown formatting
Enhanced example
Here’s a more sophisticated template that includes markdown formatting:- A blockquote (
>) for emphasis - A heading (
###) for structure - The
{{name}}variable for dynamic content
Working with different data types
TemplateMark supports various data types and formatting options:String variables
Date formatting
You can format dates using theas keyword:
2024-10-01 as 1 October 2024.
Multiple variables
You can use multiple variables in a single template:Real-world example
Here’s a complete product announcement template: Model:Template validation
The playground automatically validates your template to ensure:- All variables exist in the Concerto model
- Variable names are spelled correctly
- Data types are compatible with any formatting you’ve applied
Next steps
Now that you’ve created your template, proceed to Module 3: Data binding to generate JSON data that will populate your template variables.Key concepts
What is TemplateMark?
What is TemplateMark?
TemplateMark is a markdown-based templating language that allows you to create dynamic documents with variable placeholders. It’s part of the Accord Project’s markdown-transform library.
How do variables work?
How do variables work?
Variables in TemplateMark are enclosed in
{{ and }}. At runtime, these placeholders are replaced with actual values from your data object. Variable names must match property names in your Concerto model.Can I use markdown formatting?
Can I use markdown formatting?
Yes! TemplateMark supports full markdown syntax, including headings, lists, blockquotes, bold, italic, links, and more. You can combine any markdown with your template variables.
How do I format dates and other types?
How do I format dates and other types?
Use the
as keyword followed by a format string. For example, {{date as "YYYY-MM-DD"}} formats a date. Different data types support different formatting options.