Skip to content

Commit c0359f8

Browse files
committed
stow the created template on the parser
1 parent 2c441a3 commit c0359f8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

include/inja/parser.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Parser {
2929

3030
Lexer lexer;
3131
TemplateStorage& template_storage;
32+
std::vector<Template> template_stash;
3233
const FunctionStorage& function_storage;
3334

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

624625
Template parse(std::string_view input, std::string_view path) {
625-
auto result = Template(static_cast<std::string>(input));
626+
auto& result = template_stash.emplace_back(Template(static_cast<std::string>(input)));
626627
parse_into(result, path);
627628
return result;
628629
}

single_include/inja/inja.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ class Parser {
14671467

14681468
Lexer lexer;
14691469
TemplateStorage& template_storage;
1470+
std::vector<Template> template_stash;
14701471
const FunctionStorage& function_storage;
14711472

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

20622063
Template parse(std::string_view input, std::string_view path) {
2063-
auto result = Template(static_cast<std::string>(input));
2064+
auto& result = template_stash.emplace_back(Template(static_cast<std::string>(input)));
20642065
parse_into(result, path);
20652066
return result;
20662067
}

0 commit comments

Comments
 (0)