Skip to content

Commit

Permalink
stow the created template on the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jbohanon committed Mar 14, 2024
1 parent 2c441a3 commit c0359f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/inja/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Parser {

Lexer lexer;
TemplateStorage& template_storage;
std::vector<Template> template_stash;
const FunctionStorage& function_storage;

Token tok, peek_tok;
Expand Down Expand Up @@ -622,7 +623,7 @@ class Parser {
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}

Template parse(std::string_view input, std::string_view path) {
auto result = Template(static_cast<std::string>(input));
auto& result = template_stash.emplace_back(Template(static_cast<std::string>(input)));
parse_into(result, path);
return result;
}
Expand Down
3 changes: 2 additions & 1 deletion single_include/inja/inja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ class Parser {

Lexer lexer;
TemplateStorage& template_storage;
std::vector<Template> template_stash;
const FunctionStorage& function_storage;

Token tok, peek_tok;
Expand Down Expand Up @@ -2060,7 +2061,7 @@ class Parser {
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}

Template parse(std::string_view input, std::string_view path) {
auto result = Template(static_cast<std::string>(input));
auto& result = template_stash.emplace_back(Template(static_cast<std::string>(input)));
parse_into(result, path);
return result;
}
Expand Down

0 comments on commit c0359f8

Please sign in to comment.