项目
在 GitHub 查看
kainjow/Mustache
关于
适用于现代 C++ 的 Mustache 文本模板
其他项目可以做什么
- Inverted Sections
- Custom escape function for use outside of HTML
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文About
- 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
探索相关项目
加载中…