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
Oscar Rambla
2004-12-14
On Tuesday 14 December 2004 10:43, you 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?

Well, I can't answer it yet but  If you force me I would say that it's
convenient.

> > Also in Python 2.4 an arbitrary mapping can be provided as a single
> > argument.
>
> I don't understand.  Do you mean as an argument to the '%' operator?
> I think that *does* work with htmltext in 2.0a3.

I think my confussion came while trying to compare PTL function args with
 that of Python Template.  Then I forgot that PTL still has other mechanism
 to support this.

I guess Python Template are even still possible inside a  PTL:

b="b"

def printa[plain]():
  a="a"

  string.Template("a es $a, b es $$b ").safe_substitute(globals())

-Oscar Rambla


reply