Skip to content

Invalid GAE templates generated #24

Closed
evgenyz opened this Issue Oct 6, 2010 · 1 comment

2 participants

@evgenyz
evgenyz commented Oct 6, 2010

Problem is in change
http://github.com/webpy/webpy/commit/84205cf4a0495ec5a10cb2d6d9904262d9e7ad68

This change results in such a template:

from web.template import CompiledTemplate, ForLoop, TemplateResult

import snippets
# encoding: utf-8 
    join_ = main._join; escape_ = main._escape
def main (username):
    __lineoffset__ = -4
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'\n'])
    extend_([u'<tr>\n'])
    extend_([u'        <td/><td colspan="2">Hello, ', escape_(username, False), u'!</td><td/>\n'])
    extend_([u'</tr>\n'])

    return self

main = CompiledTemplate(main, './templates/main.html')

# encoding: utf-8 
    join_ = time_reports_individual._join; escape_ = time_reports_individual._escape
def time_reports_individual (periods):
...

And exception:

join_ = main._join; escape_ = main._escape
^
    IndentationError: unexpected indent

Instead this should look as this IMHO:

        code = code.replace("__template__", name, 1)

        out.write(code)

        out.write('\n\n')
        out.write('%s = CompiledTemplate(%s, %s)\n\n' % (name, name, repr(path)))
        # inject "join_ = ..; escape_ = .." into the code.. 
        # That is required to make escape functionality work correctly. 
        out.write('\njoin_ = %s._join; escape_ = %s._escape\n' % (name, name))
@anandology

fix GAE compilation issue. (closed by 75dcc97)

@s7v7nislands s7v7nislands pushed a commit to s7v7nislands/webpy that referenced this issue May 4, 2011
@anandology anandology fix GAE compilation issue. (closes #24) 75dcc97
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.