Skip to content

functions declared in filter="" attributes do not pull from the Context #3

Closed

Description

@sqlalchemy-bot

Migrated issue, originally created by Michael Bayer (@zzzeek)

i.e.

   <%namespace name="foo" file="func.html"/>
   
   <%def name="lala" filter="foo.bar">
      etc
   </%def>

the "foo" namespace will not get pulled out from the Context into the local python namespace.

Activity

  1. sqlalchemy-bot commented on Feb 21, 2011

    @sqlalchemy-bot
    Author

    Changes by Michael Bayer (@zzzeek):

    • added labels: easy
  2. sqlalchemy-bot commented on Aug 3, 2013

    @sqlalchemy-bot
    Author

    Michael Bayer (@zzzeek) wrote:

    except it does, this must have been duped at some point

    from mako.template import Template
    
    t = Template("""
       <%namespace name="foo" file="func.html"/>
    
       <%def name="lala()" filter="foo.bar">
          etc
       </%def>
    
    """)
    
    print t.code
    
    
    
    #!python
    def render_body(context,**pageargs):
        __M_caller = context.caller_stack._push_frame()
        try:
            __M_locals = __M_dict_builtin(pageargs=pageargs)
            foo = _mako_get_namespace(context, 'foo')
            __M_writer = context.writer()
            # SOURCE LINE 1
            __M_writer(u'\n   ')
            # SOURCE LINE 2
            __M_writer(u'\n\n   ')
            # SOURCE LINE 6
            __M_writer(u'\n\n')
            return ''
        finally:
            context.caller_stack._pop_frame()
    
    
    def render_lala(context):
        __M_caller = context.caller_stack._push_frame()
        try:
            context._push_buffer()
            foo = _mako_get_namespace(context, 'foo')
            __M_writer = context.writer()
            # SOURCE LINE 4
            __M_writer(u'\n      etc\n   ')
        finally:
            __M_buf, __M_writer = context._pop_buffer_and_writer()
            context.caller_stack._pop_frame()
        __M_writer(foo.bar(__M_buf.getvalue()))
        return ''
    
  3. sqlalchemy-bot commented on Aug 3, 2013

    @sqlalchemy-bot
    Author

    Changes by Michael Bayer (@zzzeek):

    • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions