#pragma once
#ifndef LEXESIS_TEMPLATE_H
#define LEXESIS_TEMPLATE_H

#include <map>
#include <string>
#include <vector>
#include <mstch/mstch.hpp>

namespace lxs {
namespace templ {
    /**
     * A changeable information structure for templates
     */
    using TemplateContext = mstch::node;

    /**
     * Make a TemplateContext string
     */
    TemplateContext make_string(std::string);

    /**
     * Make a TemplateContext map/dictionary
     */
    TemplateContext make_map(std::map<const std::string, TemplateContext>);

    /**
     * Make a TemplateContext array/vector
     */
    TemplateContext make_array(std::vector<TemplateContext>);

    /**
     * A generic wrapper around whichever templating system gets used
     */
    class Template {
        public:
            /**
             * Construct a Template from given filename
             *
             * @param filename The name of the file which contains the template rules
             */
            Template(std::string filename);

            /**
             * Destructor
             */
            ~Template();

            /**
             * Render this template to `out` using the information in `context`
             *
             * @param out The ostream to render to
             * @param context The information to provide the template rules while rendering
             */
            void render(std::ostream& out, TemplateContext& context);
        private:
            std::string m_filename;
    };

} //namespace templ
} //namespace lxs

#endif //LEXESIS_TEMPLATE_H
