[pmwiki-users] New {$$ } and {( )} markups [Was: Can any of the form recipes do this?]

Patrick R. Michaud pmichaud at pobox.com
Tue Apr 3 12:48:52 CDT 2007


> Tuesday, April 3, 2007, 4:54:13 PM, Patrick wrote:
> > Well, I don't know about "in a template".  My intent has always
> > been that {(...)} would be rendering markup, not something
> > substituted in a template.
> 
> Okay. Then I need more clarification. I am confused.
> Fox has used date stamping markup like {date:d.m.Y - H:i} up till now.
> I changed that today to {(date:....)}.
> This is used in templates, and Fox uses the date function to
> substitute the template placeholder for a hard string, i.e.
> something like 03.04.2007 - 17:01, to be put into the target page.
> 
> Will the {(date )} markup you propose interfere with this?

Likely, because the {(...)} markup I've been thinking of using
would be a standard markup to be rendered when a page is displayed,
not as something that appears in a template.  

> From your answer above it seems to me that Fox will need to continue
> to replace a {(date ...} pattern for timestamping posts. This is okay
> as long as there is no collusion of markups. So the date: may be
> rather helpful to retain. Or am I missing something?

Well, I think it would be confusing to (template) authors if some
{(...)} markups are replaced when a post is made, while others are
replaced when the page is displayed.  They really ought to be
different markups.

I know this starts to look terribly ugly, but one could do

   {$$(date ...)}

to indicate that the (date ...) output is to be substituted at
the time the template is expanded instead of when the page is 
displayed.  And although it's a little verbose, it is at least
consistent in that template substitutions always start to look
like {$$...}, so there's little ambiguity.

Or, we could always do funny things like having a common
prefix for functions that are intended to be done as part
of the template expansion, as in

    {(t:date ...)}
    {(t:substr ...)}
    {(t:foo ...)}

but somehow that doesn't seem a whole lot different from {$$(...)}

At any rate, I was fully intending {(...)} to be a standard
markup for doing computations at the time a page is rendered,
not as a template substitution markup.  Especially so that someday
we can possibly do things like

    (:template first {(substr {=$Group} 0 1)}:)
    {(substr {=$Group} 0 1)}

to be able to do control-breaks based on the first letter of
a group's name (e.g., for a dictionary table of contents).

> > And I much prefer the strftime date syntax to PHP's date syntax --
> > strftime is more standard, and it's much easier to write things like:
> >     {(date fmt="Today is %Y-%m-%d")}
> > than to write
> 
> >     {(date fmt="\T\o\d\a\y\ \i\s Y-m-d")}
> 
> Why do you want to put "Today is " into the markup, and not have it
> outside: Today is {(date Y-m-d)} ?

Sorry, bad example.  Try this one:

    {(date fmt="%b %d, %Y at %H:%M %P")}

versus

    {(date fmt="F j, Y \a\t h:i A")}

To me, the PHP date specification just feels wrong because it's
difficult to distinguish normal letters from formatting options.
And while many programming languages and systems use strftime [1], 
as far as I know PHP is the only one that uses its particular
formatting syntax.  So, there's more reference material available
for people who want to format dates and times using the strftime
syntax.

But we could support both, with something like

    {(phpdate ...)}

or

    {(date phpfmt="Y-m-d")}

Pm

[1]  Languages that use strftime() %-codes for standard date/time formatting
     include C, C++, Perl, PHP, Python, Ruby, Java, Tcl, and the Unix date(1)
     command.  I've undoubtedly missed a few.





More information about the pmwiki-users mailing list