Skip to content
Andreas Wagner edited this page Nov 16, 2025 · 2 revisions

XTML – Quick Start Guide

XTML is a lightweight template engine written in C++ that allows you to generate dynamic HTML using variables, expressions, control flow, and custom functions. This page provides a short introduction on how to install, run, and use XTML.

1. Download and Installation

  • Download the latest release from the Releases page.
  • Extract the archive.
  • Ensure xtml.exe is available in your PATH or in the working directory.

No additional libraries or runtimes are required.

2. Basic Usage

To process an .xtml file and generate HTML: xtml build input.xtml

XTML writes the output HTML file in the same directory as the input.

Check the installed version: xtml version

3. Example Template

<xtml>
    var title = "XTML Demo";
    var number = 5;
    var squared = number * number;

    if (squared > 10) {
        print("Value is greater than 10");
    }
</xtml>

<h1>{{@title}}</h1>
<p>Squared: {{@squared}}</p>

Run xtml build example.xtml

Resulting output:

<h1>XTML Demo</h1>
<p>Squared: 25</p>

4. Features Overview

XTML supports:

  • Variables and expressions
  • Functions and user-defined functions
  • Loops while ``Forand conditionsif` `else if` `else`
  • Inline HTML generation
  • Side-Effects using the expr keyword to buffer the output into an variable
  • Module system for custom native functions (DLLs)
  • Native helper functions (e.g., std::randStr)

5. Modules (DLL Support)

You can extend XTML by writing your own modules in C++. A module inherits from the Module class and registers functions via the FunctionRegistry.

Modules are loaded automatically when you call a function defined inside them.

A detailed module tutorial can be found in the Modules wiki page.

6. File Structure

project/
 ├─ index.xtml
 ├─ functions.xtml   (optional)
 └─ modules/         (optional DLL extensions)

7. Support and Contributions

  • Issues and feature requests can be submitted on GitHub.
  • Pull requests are welcome.
  • The project is licensed under MIT.

Clone this wiki locally