Proyectos
Ver en GitHub
kainjow/Mustache
Acerca de
Plantillas de texto Mustache para C++ moderno
Otros proyectosWhat you can do
- Inverted Sections
- Custom escape function for use outside of HTML
Crecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalAbout
- Mustache implementation for modern C++ (requires C++11)
- Header only
- Zero dependencies
- Templated string type for compatibility with any STL-like string (std::string, std::wstring, etc)
- Boost license
Example usage
All examples assume using namespace kainjow::mustache. Additional examples and usage can be found in the tests.cpp file.
Example 1 - Hello World
mustache tmpl{"Hello {{what}}!"};
std::cout << tmpl.render({"what", "World"}) << std::endl;
// Hello World!
Example 2 - Lists
mustache tmpl{"{{#employees}}{{name}}, {{/employees}}"};
data employees{data::type::list};
employees << data{"name", "Steve"} << data{"name", "Bill"};
tmpl.render({"employees", employees}, std::cout);
// Steve, Bill,
Example 3 - Custom Render Handler
mustache tmpl("Hello {{what}}!");
std::stringstream ss;
tmpl.render({"what", "World"}, [&ss](const std::string& str) {
ss << str;
});
// ss.str() == "Hello World!"
Supported Features
This library supports all current Mustache features:
- Variables
- HTML escaping
- Sections
- Inverted Sections
- True/False
- Lists
- Lambdas
- Partials
- Comments
- Set Delimiter
Additional features:
- Custom escape function for use outside of HTML
Explorar proyectos relacionados
Cargando…