views:

48

answers:

2

In mako template, I need to do something like that :

${'foo %(a)s bar %(b)s' % {'a': '1', 'b': '2'}}

When A do that, I've this error :

SyntaxException: (SyntaxError) unexpected EOF while parsing 
(, line 1) ("'foo %(a)s bar %(b)s' % {'a': '1', 'b': '2'") in file…

Do you know a tip to fix this issue ?

I need to use this syntax in translated text : $(_(u'foo bar %(a)s ... %(b)s) % { ... })

Thanks for your help. Stephane

A: 

So a tip to work around is to pass the dict object in a different way.

e.g.:


from mako.template import Template

print Template("${'foo %(a)s bar %(b)s' % data}").render(data=dict(a='Alpha',b='Beta'))
MattH
A: 

solution : ${'foo %(a)s bar %(b)s' % dict((('a', '1'), ('b', '2'),))}

harobed