Skip to content

Templates & Code Generation

Templates are where ADL turns your metadata into something tangible. A template is a text file that mixes static content with dynamic placeholders — and when ADL processes it against your metadata, it produces real output files.

A template is written in Handlebars, a simple templating language. If you’ve ever used mail merge, the concept is similar: you write the structure you want, and mark the spots where data should be filled in.

Here’s a simplified example of what a template might look like:

CREATE TABLE [{{targetDataObject.name}}] (
{{#each targetDataObject.dataItems}}
[{{name}}] {{dataType}}{{#unless isNullable}} NOT NULL{{/unless}}{{#unless @last}},{{/unless}}
{{/each}}
);

When ADL processes this template against a Data Object called “Customer” with columns like Id, Name, and Email, it generates:

CREATE TABLE [Customer] (
[Id] INT NOT NULL,
[Name] NVARCHAR(100),
[Email] NVARCHAR(255)
);

That’s the basic idea — but templates can do much more, including conditional logic, loops, helper functions, and nested structures.

Templates can produce any text-based output. Common examples include:

  • DDL scriptsCREATE TABLE, CREATE VIEW, ALTER TABLE statements.
  • Stored procedures — ETL/ELT logic for loading and transforming data.
  • Views — Virtual tables that combine data from multiple sources.
  • Documentation — Markdown or HTML pages describing your data objects.
  • Deployment scripts — PowerShell, Bash, or SQL scripts for CI/CD pipelines.
  • Configuration files — JSON, YAML, or XML for tools and services.

If it’s text, ADL can generate it.

ADL comes with a library of ready-made templates for common data solution patterns:

  • Staging / Landing — Table creation and data loading for staging areas.
  • Persistent Staging — Delta detection and history-preserving staging patterns.
  • Data Vault — Hub, Link, and Satellite generation for Data Vault architectures.
  • Documentation — Auto-generated Markdown documentation for your data objects.
  • Control framework — Registration and deployment scripts.

These templates support SQL Server and Snowflake out of the box, and you can adapt them for other platforms.

Browse the full library in the Templates section.

To tell ADL which template to use for which data object, you create template mappings. A template mapping simply links a Data Object to a template, saying “use this template to generate output for this object.”

You can:

  • Map different templates to different objects (staging tables use one template, hubs use another).
  • Map multiple templates to the same object (generate both a table script and a documentation page for each object).
  • Use template mappings to control which objects produce output and which don’t.

Template mappings are managed from the Data Objects screen in the app.

ADL extends the standard Handlebars language with custom helper functions that make working with metadata easier. These helpers can:

  • Compare strings and values
  • Look up extension properties
  • Generate random test data
  • Format and manipulate text

See the full list of available helpers in the Handlebars Helpers section.

Here’s what happens when you generate output in ADL:

  1. ADL reads the template mappings for your data objects.
  2. For each mapping, it takes the metadata (the data object, its items, its connection) and passes it to the template.
  3. The template engine processes the Handlebars syntax, filling in placeholders with real values.
  4. The result is written to an output file in your project folder.

Each mapping produces one output file, so everything stays organized and predictable.

You can preview individual template outputs in the Code Preview screen, or generate everything at once from the Code Generator.

You can create and edit templates directly in the ADL app from the Templates screen. The built-in code editor gives you syntax highlighting and a live preview of how the template will render against your metadata.

For a hands-on walkthrough, see the Create a Custom Template guide.