diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-10-23 18:16:52 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-10-23 18:16:52 +0200 |
commit | 47a838f292439b9d1ce921a79341e4a7170d0810 (patch) | |
tree | 8f1a306632300d5895175b08222832d61aa21b59 | |
parent | f8d857d13b8ee76d7b4a03a9572257d8060ba19e (diff) |
Added Inja "prefix" callback function.
* set some config options explicitly
* fixed Inja "indent" callback skip_blank
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | src/TemplateManager.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/TemplateManager.cpp b/src/TemplateManager.cpp index 2c58306..ff14610 100644 --- a/src/TemplateManager.cpp +++ b/src/TemplateManager.cpp @@ -21,19 +21,39 @@ TemplateManager::TemplateManager() bool is_first_line = true; while (std::getline(stream, line)) { - if (is_first_line == false || args.at(2)->get<bool>() == true) + if (is_first_line == false || args.at(2)->get<bool>() == false) { if (line != "" || args.at(3)->get<bool>() == false) { line.insert(0, args.at(1)->get<std::size_t>(), ' '); } } - line += '\n'; + if (line != "" || args.at(3)->get<bool>() == false) + { + line += '\n'; + } out += line; is_first_line = false; } return out; }); + /* + * prefix(input: str, prefix: str); + */ + AddInjaCallback("prefix", 2, [](inja::Arguments & args) { + std::stringstream stream(args.at(0)->get<std::string>()); + std::string line, out; + while (std::getline(stream, line)) + { + out += args.at(1)->get<std::string>() + line + "\n"; + } + return out; + }); + + m_Inja.set_trim_blocks(true); + m_Inja.set_lstrip_blocks(true); + m_Inja.set_search_included_templates_in_files(false); + m_Inja.set_throw_at_missing_includes(true); } void TemplateManager::ParseTemplates(Filesystem & fs) |