Skip to content

<%include file="${i}"/> broken as of r228 #29

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by Anonymous

We have the following template on PylonsHQ:

<%include file="/docs/${g.current_version}/install.html"/>
<%def name="title()">${parent.title()} - Install</%def>
<%def name="nav()">Install</%def>
<%inherit file="/layout.html"/>

As of r228, the include is broken with the error:

I keep getting this wack error
Module _layout_html:59 in render_body
>>  context.write(unicode(self.yui_grid()))
Module mako.runtime:200 in <lambda>
>>  return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
Module _layout_html:100 in render_yui_grid
>>  context.write(unicode(caller.body()))
Module mako.runtime:91 in call_wno_caller
>>  return callable_(*args, **kwargs)
Module _layout_html:51 in body
>>  context.write(unicode(next.body()))
Module mako.runtime:200 in <lambda>
>>  return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
Module _install_index_html:26 in render_body
>>  runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)
NameError: global name 'g' is not defined

The .py generated for this file as of r228 is:

def render_body(context,**pageargs):
    __locals = dict(pageargs=pageargs)
    foo = context.get('foo', UNDEFINED)
    # SOURCE LINE 1
    runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

Whereas before it would do something along the lines of:

def render_body(context,**pageargs):
    __locals = dict(pageargs=pageargs)
    g = context.get('g', UNDEFINED)
    # SOURCE LINE 1
    runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

I've attached a test for this and a patch that fixes it. You probably have a better version of the patch -- what it generates now is:

def render_body(context,**pageargs):
    __locals = dict(pageargs=pageargs)
    foo = context.get('foo', UNDEFINED)
    g = context.get('g', UNDEFINED)
    # SOURCE LINE 1
    runtime._include_file(context, u'/docs/' + g.current_version + u'/install.html', _template_uri)

I suspect the 'foo' PythonCode business is some test code you left around in the r228 commit


Attachments: include_fix_r240.diff

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