[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: How to define an <expire> tag?

Hello Fritz Zaucker, in a previous mail you wrote:

> I was trying to define an <expire>-tag which is supposed to swallow
> the rest of the page (or, alternatively, its body) if it evaluates to
> true. Like the following:
> --- WML input starts below ---
> <title>Title of the page</title>
> <h1>Header</h1>
> <expire 1999/12/31>
> Whatever is going onto the page ...
> --- End of WML input file ---
> The idea is that WML does only generate HTML for what's ABOVE the
> expire tag if the date of the wml-run is past the expiration date.
> Can this be done short of putting everything inside a ePerl-tag (which
> would be a bad idea because of nesting not possible)? Any ideas from
> the WML-master?

That's easy when you know how Pass 5 (Divert) works and when you additionally
know that there is a discard location named "null". So, the idea is to insert
a enter for location "null" when the expire time is reached. Here it is:

    | <define-tag expire>
    | <:{
    |      use Date::Parse;
    |      my $et = Date::Parse::str2time('%0');
    |      my $ct = time();
    |      print '<<main..' if ($et <= $ct);
    | }:>
    | </define-tag>

It does excatly what you want. Seems like I will add this
into WML 1.6.0. But here as a container tag, so it is more useful.

> Also, while experimenting with this, I thought I could inform the user
> by writting to STDERR from within <perl> </perl>. However, this aborts
> the WML-run. Could we have a <say> </say> tag somehow to write to the
> Console?

Hmmm... that's not such easy. Currently I only have the following
as a solution:

    | <define-container say>
    | <:{
    |     open(TTY, ">/dev/tty");
    |     print TTY <<'EOT';
    | %body
    | EOT
    |     close(TTY);
    | }:>
    | </define-container>

It also does what you want, it prints to the terminal of the WML user from
within Pass 2 as you requested. But I don't know if this is the most elegant
way... Hmmmm.. Has anyone a better solution?

I really want to add such a thing to WML 1.6.0, too. 

                                       Ralf S. Engelschall
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com