mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-06-08 15:16:52 +02:00
start work on webconsole with templates
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
47460d86b2
commit
a843be75f3
60 changed files with 24925 additions and 38 deletions
37
libi2pd_webconsole/inja/template.hpp
Normal file
37
libi2pd_webconsole/inja/template.hpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef INCLUDE_INJA_TEMPLATE_HPP_
|
||||
#define INCLUDE_INJA_TEMPLATE_HPP_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "node.hpp"
|
||||
#include "statistics.hpp"
|
||||
|
||||
namespace inja {
|
||||
|
||||
/*!
|
||||
* \brief The main inja Template.
|
||||
*/
|
||||
struct Template {
|
||||
BlockNode root;
|
||||
std::string content;
|
||||
std::map<std::string, std::shared_ptr<BlockStatementNode>> block_storage;
|
||||
|
||||
explicit Template() {}
|
||||
explicit Template(const std::string& content): content(content) {}
|
||||
|
||||
/// Return number of variables (total number, not distinct ones) in the template
|
||||
int count_variables() {
|
||||
auto statistic_visitor = StatisticsVisitor();
|
||||
root.accept(statistic_visitor);
|
||||
return statistic_visitor.variable_counter;
|
||||
}
|
||||
};
|
||||
|
||||
using TemplateStorage = std::map<std::string, Template>;
|
||||
|
||||
} // namespace inja
|
||||
|
||||
#endif // INCLUDE_INJA_TEMPLATE_HPP_
|
Loading…
Add table
Add a link
Reference in a new issue