Re: Problem with undefined global vars
Dov Feldstern <[email protected]> Wed, 9 Jul 2014 19:49:30 +0300
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <CAOAivdfV5d1r2SOCfo6BJJ8MvRaB=teYwGjbx5GPmtPMHwCkNw@mail.gmail.com> |
On Wed, Jul 9, 2014 at 6:14 PM, Skip Montanaro <[email protected]> wrote: > > ${sorted(params["Accounts"].values())} > > #for $c in sorted(params["TradableSymbols"].split(",")) > <key>symbol</key> <string>${c}</string> > #end for > > #for $acct in sorted(params["Accounts"].values()) > <key>name</key> <string>${acct}</string> > #end for > It should be '$params' (without the curly braces). > If I ${...}-wrap the uses of params the compilation step fails (with a > nice Cheetah traceback). As is, it complains about the missing global > name. What am I missing? As to why -- well, I'm not sure, but the relevant error spit out by Cheetah seems to be this: Long-form placeholders - ${}, $(), $[], etc. are not valid inside expressions. Use them in top-level $placeholders only. In general, I only use the curly braces when I need them to disambiguate (for example, if immediately after $params I would want the string '_x' -- in that case, $params_x wouldn't do, while ${params}_x does. But otherwise, I do without them... BTW, same goes for 'sorted' on the first line of the template -- you can get rid of those curly braces, too... HTH! Dov ------------------------------------------------------------------------------ Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft