templating
This commit is contained in:
16
src/templating.cpp
Normal file
16
src/templating.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "templating.hpp"
|
||||
|
||||
crow::response Templating::render_template(const std::string& template_name, const inja::json& data) {
|
||||
try {
|
||||
inja::Template template_obj = inja_env.parse_template(template_name);
|
||||
std::string rendered = inja_env.render(template_obj, data);
|
||||
return crow::response(rendered);
|
||||
|
||||
} catch (const inja::RenderError& e) {
|
||||
return crow::response(500, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
crow::response Templating::render_template(const std::string& template_name) {
|
||||
return render_template(template_name, inja::json{});
|
||||
}
|
Reference in New Issue
Block a user