I have Mako taking a template from a preprocessor, and now thinks there is a 'pass' after my if statement.
Here is the complete traceback
Error !
SyntaxException: (SyntaxError) invalid syntax (, line 1) (u"if ${session['anonymous']}:pass") in file '/.../site/templates/shpaml/views/index.html' at line: 3 char: 1
1 <p>your anonymous status is ${session['anonymous']}</p>
2
3 % if ${session['anonymous']}:
4
5 <a href='/login/'>login</a>
6
7 % else:
8
/.../site/library/mako/pyparser.py, line 37:
raise exceptions.SyntaxException("(%s) %s (%s)" % (e.__class__.__name__, str(e), repr(code[0:50])), **exception_kwargs)
/.../site/library/mako/ast.py, line 30:
expr = pyparser.parse(code.lstrip(), "exec", **exception_kwargs)
/.../site/library/mako/ast.py, line 82:
super(PythonFragment, self).__init__(code, **exception_kwargs)
/.../site/library/mako/parsetree.py, line 69:
code = ast.PythonFragment(text, **self.exception_kwargs)
/.../site/library/mako/lexer.py, line 94:
node = nodecls(*args, **kwargs)
/.../site/library/mako/lexer.py, line 313:
self.append_node(parsetree.ControlLine, keyword, isend, self.escape_code(text))
/.../site/library/mako/lexer.py, line 152:
if self.match_control_line():
/.../site/library/mako/template.py, line 257:
node = lexer.parse()
/.../site/library/mako/template.py, line 93:
(code, module) = _compile_text(self, file(filename).read(), filename)
/.../site/library/mako/lookup.py, line 127:
self.__collection[uri] = Template(uri=uri, filename=posixpath.normpath(filename), lookup=self, module_filename=(self.modulename_callable is not None and self.modulename_callable(filename, uri) or None), **self.template_args)
/.../site/library/mako/lookup.py, line 85:
return self.__load(srcfile, uri)
/.../site/library/templates/__init__.py, line 25:
template = lookup_map[type].get_template(template_name)
Why would the traceback show pass but not show it in the traceback source? On top of that, it says the wrong line number. ${session['anonymous']} in line 1 returns True (if I remove the syntax error). So that doesn't have any problems.