https://github.com/madladsquad/untitledtemplatingengine
A templating engine powered by a lisp-like language
https://github.com/madladsquad/untitledtemplatingengine
c cpp library templating templating-engine templating-language
Last synced: about 1 month ago
JSON representation
A templating engine powered by a lisp-like language
- Host: GitHub
- URL: https://github.com/madladsquad/untitledtemplatingengine
- Owner: MadLadSquad
- License: mit
- Created: 2022-05-10T21:43:51.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-12-02T12:01:38.000Z (5 months ago)
- Last Synced: 2025-12-05T09:16:36.962Z (5 months ago)
- Topics: c, cpp, library, templating, templating-engine, templating-language
- Language: C++
- Homepage: https://madladsquad.com/docs/UntitledTemplatingEngine/Home
- Size: 95.7 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yaml
- License: LICENSE
Awesome Lists containing this project
README
# UntitledTemplatingEngine
[](https://lbesson.mit-license.org/)
[](https://discord.gg/4wgH8ZE)
A C and C++ templating engine powered by a lisp-like programming language with plugin support.
## Example template
This template showcases the whole standard library and what the language is capable of:
```liquid
-------------------------------------------------- STRING REPLACEMENT --------------------------------------------------
The {{ at {{ descriptors }} 0 }} {{ colour }} fox {{ at {{ actions }} a1 }} over the {{ at {{ descriptors }} 1 }} dog
------------------------------------------------------ FOR LOOPS -------------------------------------------------------
Arrays: {{ for it {{ descriptors }} {{ func This is {{ it }}
}} }}
Maps: {{ for key val {{ actions }} {{ func Key: {{ key }}
Value: {{ val }}
}} }}
Arrays using the list function: {{ for it {{ list a b c }} {{ func {{ it }} }} }}
Maps using the dict function: {{ for key val {{ dict a b c d e }} {{ func {{ key }}:{{ val }} }} }}
----------------------------------------------------- IF STATEMENTS ----------------------------------------------------
{{ if {{ == {{ value }} test }}
{{ func {{ test_val }} }}
{{ func {{ not_test_val }} }}
}}
{{ switch {{ value }}
test {{ func {{ test_val }} }}
example {{ func {{ example_val }} }}
{{ func {{ fallback_val }} }}
}}
{{ cond
{{ == {{ value }} test }}{{ func {{ test_val }} }}
{{ == {{ value }} example }}{{ func {{ example_val }} }}
{{ func {{ fallback_val }} }}
}}
----------------------------------------------------- RAW TEMPLATES ----------------------------------------------------
{{ raw {{ for a arr
{{ func
{{ a }}
}}
}}}}
---------------------------------------------------------- END ---------------------------------------------------------
```
More information about the language can be found on the
[wiki](https://github.com/MadLadSquad/UntitledTemplatingEngine/wiki/).
## Why?
Because not many templating engines for C and C++ support custom functions. When we first started this project, we
needed a templating engine for the [UVKBuildTool](https://github.com/MadLadSquad/UVKBuildTool). We first developed a
small library for substituting text, but we found that too much code on the application side was written to just output
text with the correct formatting.
Additionally, we wanted to add a static site generator mode to the
[UVKBuildTool](https://github.com/MadLadSquad/UVKBuildTool), for which, we needed more advanced templates.
## Size and performance
The parser, including its header file and the whole C++ API is around 340 SLoC. The standard library is around 360 SLoC,
while the C API is around 220 SLoC
Given that this library provides a language interpreter, the parser may be a bit slower than other dumb implementations.
However, given that the parser is really simple and does all the parsing in 1 pass, it's safe to say that it's quite
performat for what it provides.
Additionally, we offer the option to replace `std::string` and `std::map` with other custom implementations, which may
lead to massive performance gains.
## Usage, installation and learning
Documentation can be found on the [wiki](https://github.com/MadLadSquad/UntitledTemplatingEngine/wiki/).