maximebf / jinja-macro-tags

Jinja Macro Tags introduces a new syntax to call macros as well as an automatic macro loader.
MIT License
4 stars 4 forks source link

Calling a macro from inside its definition files creates infinite recursion #1

Open pakal opened 8 years ago

pakal commented 8 years ago

If I have this in a template "players\peridot_previous_days.rst" :100:

{% macro sometext() %}
This is some text
{% endmacro %}

<{ sometext }/>

Then compilation fails with infinite recursion (calling the macro "normally" works) :

...
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1033, in make
_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1090, in __in
it__
    self._body_stream = list(template.root_render_func(context))
  File "P:\Programming\Chrysalis\script_fixtures\mysteryparty\players\peridot_pr
evious_days.rst", line 1, in top-level template code

  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1033, in make
_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1090, in __in
it__
    self._body_stream = list(template.root_render_func(context))
  File "P:\Programming\Chrysalis\script_fixtures\mysteryparty\players\peridot_pr
evious_days.rst", line 1, in top-level template code

  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1033, in make
_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1090, in __in
it__
    self._body_stream = list(template.root_render_func(context))
  File "P:\Programming\Chrysalis\script_fixtures\mysteryparty\players\peridot_pr
evious_days.rst", line 1, in top-level template code

  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1033, in make
_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 1090, in __in
it__
    self._body_stream = list(template.root_render_func(context))
  File "P:\Programming\Chrysalis\script_fixtures\mysteryparty\players\peridot_pr
evious_days.rst", line 1, in top-level template code

  File "C:\Python27\lib\site-packages\jinja2\utils.py", line 350, in get
    return self[key]
RuntimeError: maximum recursion depth exceeded while calling a Python object
pakal commented 6 years ago

Patch is in my pull request : https://github.com/frascoweb/jinja-macro-tags/pull/2