aboutsummaryrefslogtreecommitdiff
path: root/src/TemplateManager.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-10-19 00:43:49 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-10-19 00:43:49 +0200
commit7b01dd8e4b1779e4c4dd782dbec87acce0f4754b (patch)
tree2e6268167fdddf209a6e8e161736f5e6aff6b7d3 /src/TemplateManager.cpp
parent51d9d23c99d77edad03e6425f3ab35a390156117 (diff)
Added blog listing sorting and template checks.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/TemplateManager.cpp')
-rw-r--r--src/TemplateManager.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/TemplateManager.cpp b/src/TemplateManager.cpp
index 99af2ad..ddde2c4 100644
--- a/src/TemplateManager.cpp
+++ b/src/TemplateManager.cpp
@@ -12,6 +12,28 @@ TemplateManager::TemplateManager()
(void)args;
return true;
});
+ /*
+ * indent(input: str, width: int, first: bool, blank: bool);
+ */
+ AddInjaCallback("indent", 4, [](inja::Arguments & args) {
+ std::stringstream stream(args.at(0)->get<std::string>());
+ std::string line, out;
+ bool is_first_line = true;
+ while (std::getline(stream, line))
+ {
+ if (is_first_line == false || args.at(2)->get<bool>() == true)
+ {
+ if (line != "" || args.at(3)->get<bool>() == false)
+ {
+ line.insert(0, args.at(1)->get<std::size_t>(), ' ');
+ }
+ }
+ line += '\n';
+ out += line;
+ is_first_line = false;
+ }
+ return out;
+ });
}
void TemplateManager::ParseTemplates(Filesystem & fs)