Skip to content
6 changes: 6 additions & 0 deletions src/main/java/com/hubspot/jinjava/lib/tag/FromTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
Map<String, String> imports = getImportMap(helper);

try {
interpreter
.getContext()
.getCurrentPathStack()
.push(templateFile, tagNode.getLineNumber(), tagNode.getStartPosition());

Copy link
Contributor

Choose a reason for hiding this comment

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

You could use ImportTag#parseTemplateAsNode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point. Updated to do so and moved context stack popping into the finally block to match ImportTag.

String template = interpreter.getResource(templateFile);
Node node = interpreter.parse(template);

Expand All @@ -98,6 +103,7 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
child.render(node);
} finally {
JinjavaInterpreter.popCurrent();
interpreter.getContext().getCurrentPathStack().pop();
}

interpreter.addAllChildErrors(templateFile, child.getErrorsCopy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public String getEagerTagImage(TagToken tagToken, JinjavaInterpreter interpreter
String templateFile = maybeTemplateFile.get();
try {
try {
interpreter
.getContext()
.getCurrentPathStack()
.push(templateFile, tagToken.getLineNumber(), tagToken.getStartPosition());

String template = interpreter.getResource(templateFile);
Node node = interpreter.parse(template);

Expand All @@ -95,6 +100,7 @@ public String getEagerTagImage(TagToken tagToken, JinjavaInterpreter interpreter
output = child.render(node);
} finally {
JinjavaInterpreter.popCurrent();
interpreter.getContext().getCurrentPathStack().pop();
}

interpreter.addAllChildErrors(templateFile, child.getErrorsCopy());
Expand Down
Loading