Template parse error for latex template

44 views
Skip to first unread message

Anton Bessonov

unread,
Nov 4, 2009, 9:46:42 PM11/4/09
to python-...@googlegroups.com
I'm using template part to generating latex files. My trouble is:

\includegraphics[width=3cm]{{{ some_image }}}

I get exception:

Traceback (most recent call last):
File "/tornado/web.py", line 688, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "index.py", line 92, in get
tex = markup.parse(self.render_string('curriculum_vitae.tex',
profile=profile), 'latex')
File "/tornado/web.py", line 387, in render_string
t = RequestHandler._templates[template_path].load(template_name)
File "/tornado/template.py", line 184, in load
self.templates[name] = Template(f.read(), name=name, loader=self)
File "/tornado/template.py", line 108, in __init__
self.compiled = compile(self.code, self.name, "exec")
File "curriculum_vitae.tex", line 44
if isinstance(_tmp, str): _buffer.append(_tmp)
^
SyntaxError: invalid syntax

This isn't elegant and not enough tested solution:

--- a/tornado/template.py
+++ b/tornado/template.py
@@ -457,7 +457,7 @@ def _parse(reader, in_block=None):
return body
# If the first curly brace is not the start of a special token,
# start searching from the character after it
- if reader[curly + 1] not in ("{", "%"):
+ if reader[curly + 1] not in ("{", "%") or reader[curly + 2]
== '{':
curly += 1
continue
break

But it would be not bad if I can use templates without patching tornado
"at home".

Skylar Saveland

unread,
Nov 5, 2009, 5:40:32 PM11/5/09
to Tornado Web Server
I'm interested to hear more and maybe try to help with your issue.
I'm a fan of LaTeX, you can email me directly if you want (I'm not
really in the mood to read tracebacks on my phone right now ;)

Bret Taylor

unread,
Nov 5, 2009, 6:21:12 PM11/5/09
to python-...@googlegroups.com
That seems reasonable - we can incorporate a patch like this soon.

Anton Bessonov

unread,
Dec 16, 2009, 7:55:49 AM12/16/09
to python-...@googlegroups.com
Hi Bret,

what about this?

Best regards,

Anton

Bret Taylor schrieb:
> That seems reasonable - we can incorporate a patch like this soon.
>
> On Wed, Nov 4, 2009 at 6:46 PM, Anton Bessonov <exe...@googlemail.com
> <mailto:exe...@googlemail.com>> wrote:
>
>
> I'm using template part to generating latex files. My trouble is:
>
> \includegraphics[width=3cm]{{{ some_image }}}
>
> I get exception:
>
> Traceback (most recent call last):
> File "/tornado/web.py", line 688, in _execute
> getattr(self, self.request.method.lower())(*args, **kwargs)
> File "index.py", line 92, in get
> tex = markup.parse(self.render_string('curriculum_vitae.tex',
> profile=profile), 'latex')
> File "/tornado/web.py", line 387, in render_string
> t = RequestHandler._templates[template_path].load(template_name)
> File "/tornado/template.py", line 184, in load
> self.templates[name] = Template(f.read(), name=name, loader=self)
> File "/tornado/template.py", line 108, in __init__
> self.compiled = compile(self.code, self.name <http://self.name>,
Reply all
Reply to author
Forward
0 new messages