Mustache is a web template system with implementations available for several programming languages, including C++.
Mustache is described as a logicless system because it does not have any control flow instructions, however, both looping and conditional evaluation can be achieved using section tag processing lists and anonymous functions (lambdas).
This library supports all current Mustache features:
True | False |
Custom escape function for use outside of HTML
The ease starts with installation, just:
git clone https://github.com/kainjow/Mustache
sudo install -v Mustache/mustache.hpp /usr/local/include/
rm -rf Mustache/
Create a file: main.cpp
:
#include <iostream>
#include <mustache.hpp>
int main(){
kainjow::mustache::mustache tmpl("Hello !");
std::cout << tmpl.render({"what", "World"}) << '\n';
}
Alternatively you can use:
using namespace kainjow::mustache;
=}
Compile:
g++ main.cpp
Rotate:
./a.out
Probable output:
Hello World!
If you want to test first:
git clone https://github.com/kainjow/Mustache
cd Mustache
sed -i "s/VERSION.*/VERSION $(cmake --version | grep -o [0-9].*))/g" CMakeLists.txt
cmake -B build .
cd build && make
./tests/mustache-unit-tests
For more information visit: https://github.com/kainjow/Mustache.
Alternatives to this Mustache:
https://github.com/no1msd/mstch | https://mustache.github.io/ |