Templates & Code Generation
Templates description 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.
What’s a template?
Section titled “What’s a template?”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 table_chart 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.
What can you generate?
Section titled “What can you generate?”Templates can produce any text-based output. Common examples include:
- DDL scripts —
CREATE TABLE,CREATE VIEW,ALTER TABLEstatements. - 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.
Bundled example templates
Section titled “Bundled example templates”ADL ships example templates as part of its sample solutions — illustrations of one way to generate code for common patterns. Examples cover:
- 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, both as virtual views and physical tables.
- Documentation — Auto-generated Markdown documentation for your data objects.
- Control framework — Registration and deployment scripts.
These examples target SQL Server and Snowflake out of the box, with a preview of Microsoft Fabric (PySpark).
Templates are not a fixed library. They are starting points — illustrative of one set of opinionated choices about technology, modeling methodology, hashing, naming, change detection, and more. The same metadata can drive any text-based output you want to generate; if a bundled template makes a choice you disagree with, change it or write your own. See the Templates reference for how the examples are organized and what each one assumes.
Template mappings
Section titled “Template mappings”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.
Handlebars helpers
Section titled “Handlebars helpers”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.
The generation workflow
Section titled “The generation workflow”Here’s what happens when you generate output in ADL:
- ADL reads the template mappings for your data objects.
- For each mapping, it takes the metadata (the data object, its items, its connection) and passes it to the template.
- The template engine processes the Handlebars syntax, filling in placeholders with real values.
- 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.
Writing your own templates
Section titled “Writing your own templates”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.
What’s next?
Section titled “What’s next?”- Handlebars Helpers — Explore the custom helper functions available in your templates.
- Template Library — Browse the built-in templates.
- Code Generator — Learn how to generate output in the app.