XTML – A C++ Template Engine for HTML
I’ve been working on XTML, a small C++ utility for processing template files and generating dynamic HTML. It’s not a framework or a CMS, just a templating tool with a clear evaluation pipeline: Lexer → Parser → AST → Evaluation.
**Features**
* **Variables & Placeholders:** Define variables and use `{{@varName}}` in templates.
* **Conditional Logic & Loops:** `if`, `else`, `while` for dynamic generation.
* **Expression Evaluation:** Supports math, string operations, and arrays.
* **Function & Module System:** Define functions in templates or extend via C++ DLL modules.
* **HTML Blocks in Expressions:** You can generate HTML directly from evaluated expressions.
**Example**
<xtml>
var title = "XTML Example";
var num1 = 10;
var num2 = 5;
var sum = num1 + num2;
</xtml>
<html>
<head>
<title>{{@title}}</title>
</head>
<body>
<p>Sum: {{@sum}}</p>
</body>
</html>
**Output:**
<html>
<head>
<title>XTML Example</title>
</head>
<body>
<p>Sum: 15</p>
</body>
</html>
XTML is meant as a developer tool: you can include files, define functions, and extend it with your own modules. It uses a proper parsing pipeline so that templates are parsed into an AST, evaluated in a controlled context, and rendered efficiently.
It’s open-source under the MIT License. Feedback or suggestions for improvement are very welcome!
You can find the project here [Andy16823/xtml](https://github.com/Andy16823/xtml/tree/main) within the wiki you can find an short documentation and getting started guide.
https://redd.it/1oyjuov
@r_cpp
Post #24259
13