chameleon: getting started

12 views
Skip to first unread message

ru...@yahoo.com

unread,
Sep 13, 2011, 6:08:28 PM9/13/11
to pylons-discuss
i am complete newb with chameleon (downloaded 30 minutes ago) and am
having a problem with basic use.

based on the docs,
http://chameleon.repoze.org/docs/latest/library.html#getting-started
i do (in python 2.7.1)

>>> from chameleon import PageTemplate
>>> template = PageTemplate("<div>Hello, $name.</div>")
>>> template(name='John')
u'<div>Hello, $name.</div>'

why does not the template variable get substituted?

ru...@yahoo.com

unread,
Sep 13, 2011, 11:59:25 PM9/13/11
to pylons-discuss
Answering my own question, it should be of course,

template = PageTemplate("<div>Hello, ${name}.</div>")

Apparently the curly brackets got nuked in the documentation.
Sorry for not reading further before posting.

Phoebe Pei

unread,
Sep 13, 2011, 11:57:46 PM9/13/11
to pylons-discuss
You lost the $ before {name}
the variables in chameleon must be started with a '$'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Malthe Borch

unread,
Sep 14, 2011, 3:17:50 AM9/14/11
to pylons-...@googlegroups.com
On 14 September 2011 00:08, ru...@yahoo.com <ru...@yahoo.com> wrote:
> u'<div>Hello, $name.</div>'
>
> why does not the template variable get substituted?

Sorry about that.

It was changed in 2.1. After this release, you must use brackets.

I'll update the documentation right away.

Thanks,

\malthe

Reply all
Reply to author
Forward
0 new messages