#pragma once

#include "File.h"
#include "TemplateFile.h"

#include <vector>
#include <string>
#include <memory>
#include <unordered_map>

class TemplateSubstitutionContext;

class TemplatingEngine
{
public:
    TemplatingEngine(const Path& workingDirectory);

    std::string renderTemplate(const std::string& name, TemplateSubstitutionContext* substitutionContext);

private:
    TemplateFile* getTemplateFile(const std::string& name);
    TemplateFile* getTemplateFile(const Path& path);

    void loadTemplateFiles();
    void processTemplate(TemplateFile* file, TemplateNode* parent = nullptr);

    std::unordered_map<std::string, std::unique_ptr<TemplateFile> > mTemplateFiles;
    Path mWorkingDirectory;
    std::string mTemplateExtension{ ".html" };
};
