Inja  3.4.0
A Template Engine for Modern C++
config.hpp
1 #ifndef INCLUDE_INJA_CONFIG_HPP_
2 #define INCLUDE_INJA_CONFIG_HPP_
3 
4 #include <functional>
5 #include <string>
6 
7 #include "template.hpp"
8 
9 namespace inja {
10 
14 struct LexerConfig {
15  std::string statement_open {"{%"};
16  std::string statement_open_no_lstrip {"{%+"};
17  std::string statement_open_force_lstrip {"{%-"};
18  std::string statement_close {"%}"};
19  std::string statement_close_force_rstrip {"-%}"};
20  std::string line_statement {"##"};
21  std::string expression_open {"{{"};
22  std::string expression_open_force_lstrip {"{{-"};
23  std::string expression_close {"}}"};
24  std::string expression_close_force_rstrip {"-}}"};
25  std::string comment_open {"{#"};
26  std::string comment_open_force_lstrip {"{#-"};
27  std::string comment_close {"#}"};
28  std::string comment_close_force_rstrip {"-#}"};
29  std::string open_chars {"#{"};
30 
31  bool trim_blocks {false};
32  bool lstrip_blocks {false};
33 
34  void update_open_chars() {
35  open_chars = "";
36  if (open_chars.find(line_statement[0]) == std::string::npos) {
37  open_chars += line_statement[0];
38  }
39  if (open_chars.find(statement_open[0]) == std::string::npos) {
40  open_chars += statement_open[0];
41  }
42  if (open_chars.find(statement_open_no_lstrip[0]) == std::string::npos) {
43  open_chars += statement_open_no_lstrip[0];
44  }
45  if (open_chars.find(statement_open_force_lstrip[0]) == std::string::npos) {
46  open_chars += statement_open_force_lstrip[0];
47  }
48  if (open_chars.find(expression_open[0]) == std::string::npos) {
49  open_chars += expression_open[0];
50  }
51  if (open_chars.find(expression_open_force_lstrip[0]) == std::string::npos) {
52  open_chars += expression_open_force_lstrip[0];
53  }
54  if (open_chars.find(comment_open[0]) == std::string::npos) {
55  open_chars += comment_open[0];
56  }
57  if (open_chars.find(comment_open_force_lstrip[0]) == std::string::npos) {
58  open_chars += comment_open_force_lstrip[0];
59  }
60  }
61 };
62 
66 struct ParserConfig {
67  bool search_included_templates_in_files {true};
68 
69  std::function<Template(const std::string&, const std::string&)> include_callback;
70 };
71 
75 struct RenderConfig {
76  bool throw_at_missing_includes {true};
77 };
78 
79 } // namespace inja
80 
81 #endif // INCLUDE_INJA_CONFIG_HPP_
Class for lexer configuration.
Definition: config.hpp:14
Class for parser configuration.
Definition: config.hpp:66
Class for render configuration.
Definition: config.hpp:75
The main inja Template.
Definition: template.hpp:17