**Migrated issue, originally created by Michael Bayer ([@zzzeek](https://github.com/zzzeek))** this is related to #3 but seems different from mako.template import Template x = Template(""" X: ${"asdf" | h.foo} """) y = Template(""" Y: ${"asdf" | z.foo} """) z = Template(""" Z: ${h} ${"asdf" | h.foo} """) class h(object): foo = str try: print x.render(h=h) except NameError, e: print e print y.render(z=h) print z.render(h=h)