summaryrefslogtreecommitdiff
path: root/src/Filesystem.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-06-20 16:49:10 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-06-20 16:49:10 +0200
commit93d69841064fd5c3156d989caf7ddec46bfb8685 (patch)
tree71dc8675e27c2ac4608114efbbb3e8b81430587d /src/Filesystem.cpp
parent1967e3465c7e82d84dc8441ba1993a55050766fb (diff)
Inja/Template stuff
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/Filesystem.cpp')
-rw-r--r--src/Filesystem.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Filesystem.cpp b/src/Filesystem.cpp
index 18b8725..022c1a5 100644
--- a/src/Filesystem.cpp
+++ b/src/Filesystem.cpp
@@ -42,13 +42,22 @@ bool Filesystem::AddSingleFile(std::string path, std::string root) {
}
std::string relpath = make_path_relative(path, root);
- if (files.count(relpath) > 0) {
+ if (m_Files.count(relpath) > 0) {
std::cout << "Adding file: " << path << " and overwriting " << relpath
<< std::endl;
} else {
std::cout << "Adding file: " << path << " as " << relpath << std::endl;
}
- files[relpath] = fd;
+
+ std::string ext = std::filesystem::path(relpath).extension();
+ if (ext == ".html" || ext == ".tmpl")
+ {
+ std::string tmpl(fd.data.data(), fd.data.data() + fd.data.size());
+ m_Templates[relpath] = inja::Template(tmpl);
+ std::cout << "File: " << relpath << " may contain a renderable template." << std::endl;
+ } else {
+ m_Files[relpath] = fd;
+ }
return true;
}
@@ -59,3 +68,13 @@ bool Filesystem::Scan(std::string root) {
}
return true;
}
+
+void Filesystem::AddInjaCallback(std::string functionName, std::size_t numberOfArgs, inja::CallbackFunction function)
+{
+ m_Inja.add_callback(functionName, numberOfArgs, function);
+}
+
+void Filesystem::AddVoidInjaCallback(std::string functionName, std::size_t numberOfArgs, inja::VoidCallbackFunction function)
+{
+ m_Inja.add_void_callback(functionName, numberOfArgs, function);
+}