wrouesnel / p2cli

pongo2 cli - like the j2cli package in python, but compiles to self-contained go executables
GNU General Public License v2.0
87 stars 19 forks source link

Imported Macro Calls Fail to Execute Other Macros #63

Open Dragon-Git opened 10 months ago

Dragon-Git commented 10 months ago

Problem Description

When calling other macros within an imported macro, it has been observed that the calls do not execute as intended.

Environment

Reproduce

common.tpl

{% macro inner_test() export %}innertest{% endmacro %}

{% macro outter_test() export %}
outtertest begin
{{ inner_test() }}
outtertest end
{% endmacro %}

{{outter_test()}}

Macros calls are executed correctly

> p2 -t common.tpl

outtertest begin
innertest
outtertest end

Create another template and import the outter_test macro test.txt .

begin
{% import "common.tpl" outter_test %}{{outter_test()}}
end

Render test.txt, the contents of inner_test() are missing.

> p2 -t test.txt  
begin

outtertest begin

outtertest end

end