Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid GAE templates generated #24

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

Invalid GAE templates generated #24

evgenyz opened this issue Oct 6, 2010 · 1 comment
Milestone

Comments

@evgenyz
Copy link

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
Copy link
Member

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

No branches or pull requests

2 participants