Inja 3.5.0
A Template Engine for Modern C++
Loading...
Searching...
No Matches
template.hpp
1#ifndef INCLUDE_INJA_TEMPLATE_HPP_
2#define INCLUDE_INJA_TEMPLATE_HPP_
3
4#include <map>
5#include <memory>
6#include <string>
7
8#include "node.hpp"
9#include "statistics.hpp"
10
11namespace inja {
12
16struct Template {
17 BlockNode root;
18 std::string content;
19 std::map<std::string, std::shared_ptr<BlockStatementNode>> block_storage;
20
21 explicit Template() {}
22 explicit Template(std::string content): content(std::move(content)) {}
23
25 size_t count_variables() const {
26 auto statistic_visitor = StatisticsVisitor();
27 root.accept(statistic_visitor);
28 return statistic_visitor.variable_counter;
29 }
30};
31
32using TemplateStorage = std::map<std::string, Template>;
33
34} // namespace inja
35
36#endif // INCLUDE_INJA_TEMPLATE_HPP_
Definition node.hpp:70
A class for counting statistics on a Template.
Definition statistics.hpp:11
The main inja Template.
Definition template.hpp:16
size_t count_variables() const
Return number of variables (total number, not distinct ones) in the template.
Definition template.hpp:25