On Thu, Aug 19, 2004 at 07:22:09PM -0400, Raymond Hettinger wrote: | IDLE 1.1a2 | >>> from Cheetah.Template import Template | >>> t = Template('the $rank is $@ a $$ dead ${rank}! $') | >>> t.rank='king' | >>> print t | the king is $@ a $$ dead king! $ I second this behavior. Besides the missing 's', the second most common error is not escaping the %, for example, <table width="100%"> is painful, especially when you go through two or three stages of substitution. The behavior of Cheetah reflects real-world experience. Most of the time your templates are edited by HTML monkeys or people writing form letters or help screens. If a substitution fails, it will be obvious. This is one case where being explict causes more problems than it fixes. I've found Cheetah's implementation to be quite useful and would hope that any 'standard' template mechanism would be advised by the good work Chuck Esterbrook and Mike Orr. The other mechanism I like is the dotted notation to traverse objects. Also, I really like Cheetah's mechanism where the template object doubles as a dictionary of values. In particular, it would be nice to put default values, during substitution, it would first look in the dictionary applied via the % operator. If a key is not found in the applied dictionary, it would use the values given by the template itself. And, if cast to a string, it would only use the template's key values. If this feature was implemented, it'd be great to use keyword arguments as default mapping values. >>> t = Template("$foo $bar $bing",foo='wibbles',bar='womble') >>> print t wibbles womble $bing >>> print t % {'bar': 'bingles'} wibbles bingles $bing >>> t.bing = 'wicken' >>> t wibbles womble wicken Cheers, Clark
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4