70nlohmann::json InjaBridge::toInjaJson(
const QJsonObject &obj)
72 nlohmann::json result = nlohmann::json::object();
74 for (
const auto &[key, value] : obj.asKeyValueRange())
75 result[key.toString().toUtf8().toStdString()] = toInjaJson(value);
109QString InjaBridge::render(
const QString &templateStr,
const QJsonObject &data)
111 inja::Environment env;
112 nlohmann::json jsonData = toInjaJson(data);
114 std::string templateUtf8 = templateStr.toUtf8().toStdString();
115 std::string resultUtf8 = env.render(templateUtf8, jsonData);
117 return QString::fromUtf8(resultUtf8.c_str());
129QString InjaBridge::renderFile(
const QString &templatePath,
const QJsonObject &data)
131 inja::Environment env;
132 nlohmann::json jsonData = toInjaJson(data);
134 std::string pathUtf8 = templatePath.toUtf8().toStdString();
135 std::string resultUtf8 = env.render_file(pathUtf8, jsonData);
137 return QString::fromUtf8(resultUtf8.c_str());