Invalid GAE templates generated #24

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

Comments

Projects
None yet
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

This comment has been minimized.

Show comment
Hide comment
@anandology

anandology Oct 6, 2010

Member

fix GAE compilation issue. (closed by 75dcc97)

Member

anandology commented Oct 6, 2010

fix GAE compilation issue. (closed by 75dcc97)

This issue was closed.

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