Dieter Maurer writes:
> The existing "quote features" name the context for which quoting
> is needed. The context determines what needs to be quoted and
> how quoting has to be done.
> Your proposal does not state the context but only the how.
> Otherwise, I would think such an extension would be good.

You are right here. I just came up with "slash_quote" off the top of my
head. "string_quote" is a good language-neutral name I think that is similar
in spirit to the present format options.

> Thus, I propose:

> 1. new quoting directive "string_quote" quoting Python strings
>    i.e. ", ' and \ are quoted.
>    This would work for Javascript (and other languages with
>    C-like quotation and string literals), too.

> 2. all auxiliary functions for DTML tags, especially quoting,
>    should be available via the namespace.

>    To avaid namespace pollution, they may go into a separate
>    module, say 'aux'.
>    E.g. I would like to use quoting, formatting etc.
>    inside DTML embedded Python expressions in a form like that:

>   <dtml-var "... _.aux.fmt(x,'%m/%d/%Y')...">
>    and
>    <dtml-var ".... _.aux.sql_quote(x)...">

This idea has merit, and extends the usefulness of these options to parts of
an expression rather than just the whole thing. I think calling the module
'aux' might not be the best for code readability sake though. Perhaps it
should just be called fmt or format. Perhaps like so:

<dtml-var "... _.fmt.expr(x, '%.2f') ...">
<dtml-var "... _.fmt.string_quote(x) ...">

newbie format methods could be added too (Feature creep alert!) like:

<dtml-var "... _.fmt.currency(x) ...">

in place of the first one.

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to