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

Re: [ic] Adding a system wide module


On Tue, 1 Feb 2005, Jeff Fearn wrote:

The you can call it in a GlobalSub or UserTag, and perhaps even in a [perl global=1] block, provided that you have the catalog in the AllowGlobal configuration string.

Does this mean that I need to write a wrapper for every function I
wanted to use from Date::Calc?

I was hoping to be able to bypass the Tag stuff entirely, just using
[perl] and writting perl code in that on html pages.

If all you want is to pass through arguments to various subroutines in Date::Calc, you could create a global usertag wrapper like this:


    UserTag date-calc addAttr
    UserTag date-calc Routine <<EOR

    use Date::Calc;

    sub {
        my ($opt) = @_;
        my $out = eval "return Date::Calc::$opt->{op}(suppressed>{args}})";
            if ($@) {
                    logError("tag date-calc error: $@");
                    return;
            }
            return $out;
    }
    EOR


You call the tag like this:

    [date-calc op=Day_of_Year args.0=2004 args.1=12 args.2=31]

I tested this code and it actually works. :)

Jon


--
Jon Jensen
End Point Corporation
http://www.endpoint.com/
Software development with Interchange, Perl, PostgreSQL, Apache, Linux, ...
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.