Enhancement

Add /render interface to directly render a template as output content.
Add find as a template function.
Add filtering out token as a template variable.
This commit is contained in:
Tindy X committed 2020-04-13 20:47:17 +08:00
1 parent 983686a19e
commit 3b81dce730
4 files changed
+53

No files matched your search

+5
View File
@@ -50,6 +50,11 @@ int render_template(const std::string &content, const template_args &vars, std::
std::string data = args.at(0)->get<std::string>();
return trim(data);
});
m_callbacks.add_callback("find", 1, [](inja::Arguments &args)
{
std::string src = args.at(0)->get<std::string>(), target = args.at(1)->get<std::string>();
return regFind(src, target);
});
m_callbacks.add_callback("replace", 3, [](inja::Arguments &args)
{
std::string src = args.at(0)->get<std::string>(), target = args.at(1)->get<std::string>(), rep = args.at(2)->get<std::string>();