durusmail: quixote-users: Support $-substitution in templates
Support $-substitution in templates
2004-12-14
2004-12-14
2004-12-14
2004-12-14
2004-12-16
2004-12-16
2004-12-17
2004-12-17
2004-12-14
2005-01-01
2004-12-14
Support $-substitution in templates
Mike Orr
2004-12-14
On Tue, Dec 14, 2004 at 01:43:54PM -0500, David Binger wrote:
>
> On Dec 14, 2004, at 1:59 PM, Oscar Rambla wrote:
>
> >In Quixote 2.0a2:
> >
> >  * Support $-substitution in templates, as in Python 2.4's
> >string.Template
> >    class.  $-substitution is applied to every '$'-containing literal
> >in a
> >    template.  Templates written before this change, if they contain
> >literals
> >    containing '$', *must* be converted by replacing each '$' with
> >'$$'.
> >
> >I realized that PTL templates functions use local scope for resolving
> >$parameters.
>
> The 2.0a3 ptl compiler essentially replaces '$foo' with '"%(foo)s" %
> vars()'.
> Does anyone like or dislike this feature?

I found this one of the significant advances of Quixote 2.  "$" prevents
the need to split strings or put the referent away from its placeholer.
This makes it easier to visualize the output from the template, because
everything is in order and there aren't any extra line breaks or quoting
in the middle.

It would be nice if Python 2.4 were universal at this point and we
wouldn't need this, but it will take a year before everybody can
upgrade.  My application for instance has to run on a Mac, and
Macintoshes are still at Python 2.3.0, and Apple installed it in such a
way that upgrading it is just asking for trouble.

It would be nice if Quixote's substitution recognized global variables
too.  Otherwise you have to assign them to local variables with
different names or use the default-argument kludge.  But that's a less
significant issue.

--
-Mike Orr (aka. Sluggo), mso@oz.net  (iron@sense-sea-MegaSub-1-465.oz.net)
   http://sluggo.kicks-ass.org/                  Cxu vi parolas Esperante?

reply