aboutsummaryrefslogtreecommitdiff
path: root/src/TemplateManager.cpp
diff options
context:
space:
mode:
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)