Issues

Issue #170 resolved

using caller inside of <%call> can be polluted

Mike Bayer
repo owner created an issue

moving the call to <%self:A> below the caller changes to an endless loop, removing the <%self:A> call altogether removes the issue. So <%self:A> is affecting the identity of caller and it appears to be a codegen issue.

  1. !python from mako.template import Template

x = """ <%def name="A()"> A ${caller.body()} </%def>

<%def name="B()"> B ${caller.body()} </%def>

<%def name="C()"> C <%self:B> <%self:A> A body </%self:A> B body ${caller.body()} </%self:B> </%def>

<%self:C> C body </%self:C> """ t = Template(x) print t.code print t.render()

Comments (2)

  1. Mike Bayer reporter

    and here is the patch

    1. !diff diff -r 4f554cb3f613ed8910ea3524a0787b3b726ea6ae mako/codegen.py --- a/mako/codegen.py Fri Jul 08 10:09:03 2011 -0400 +++ b/mako/codegen.py Fri Aug 05 17:33:21 2011 -0400 @@ -847,10 +847,10 @@

    self.printer.writelines(

    1. get local reference to current caller, if any - "caller = context.caller_stack._get_caller()", + "M_caller = context.caller_stack._get_caller()",
    2. push on caller for nested call "context.caller_stack.nextcaller = " - "runtime.Namespace('caller', context, callables=ccall(caller))", + "runtime.Namespace('caller', context, callables=ccall(M_caller))", "try:") self.write_source_comment(node) self.printer.writelines(
  2. Log in to comment