From 7b01dd8e4b1779e4c4dd782dbec87acce0f4754b Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 19 Oct 2021 00:43:49 +0200 Subject: Added blog listing sorting and template checks. Signed-off-by: Toni Uhlig --- src/TemplateManager.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/TemplateManager.cpp') 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 line, out; + bool is_first_line = true; + while (std::getline(stream, line)) + { + if (is_first_line == false || args.at(2)->get() == true) + { + if (line != "" || args.at(3)->get() == false) + { + line.insert(0, args.at(1)->get(), ' '); + } + } + line += '\n'; + out += line; + is_first_line = false; + } + return out; + }); } void TemplateManager::ParseTemplates(Filesystem & fs) -- cgit v1.2.3