templating

This commit is contained in:
2025-08-21 21:15:21 +01:00
parent a7404fed3d
commit 217adf91e9
16 changed files with 58 additions and 10 deletions

16
src/templating.cpp Normal file
View 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{});
}