Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stow the created template on the parser #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it seems like it might be more correct to use make_shared to handle this

parse_into(result, path);
return result;
}
Expand Down
Loading