[ic] interpolate

Jon prtyof5 at attglobal.net
Sat Mar 25 11:24:32 EST 2006



Elver Loho wrote:

> On 3/25/06, Kevin Walsh <kevin at cursor.biz> wrote:
> > "Elver Loho" <elver.loho at gmail.com> wrote:
> > > On 3/24/06, Kevin Walsh <kevin at cursor.biz> wrote:
> > > > "Elver Loho" <elver.loho at gmail.com> wrote:
> > > > Well, firstly, it looks as if you're mixing positional and named
> > > > parameters.  You can either do [lc2 first second] or
> > > > [lc2 foo=first bar=second], but not mix the two.  That'll be
> > > > the reason why you always get the default message when you do that.
> > >
> > > How do I unpack named variables? Right now am using my ($code, $message) = @_;
> > >
> > If you have a UserTag like this:
> >
> >     UserTag foobar Order foo bar baz
> >
> > then you have three named arguments, which you can use like this:
> >
> >     [foobar foo="aaa" bar="bbb" baz="ccc"]
> >
> > You can put the args in any order you like.  The tag code will receive
> > them in the order you specified in the UserTag "Order" config.
> >
> > In your UserTag code, you can collect the args like this:
> >
> >     my ($foo,$bar,$baz) = @_;
> >
> > The variable names are irrelevant, but it's useful to name them after
> > the Order values.
> >
> > If you make your UserTag into a container, like this:
> >
> >     UserTag foobar HasEndTag 1
> >     UserTag foobar Order     foo bar baz
> >
> > then you can use your tag like this:
> >
> >     [foobar foo="aaa" bar="bbb" baz="ccc"] Tag body [/foobar]
> >
> > Now you have an extra argument, which you collect like this:
> >
> >     my ($foo,$bar,$baz,$body) = @_;
> >
> > If you want your tag body to be interpolated by default (no need
> > to specify interpolate=1) then you define it like this:
> >
> >     UserTag foobar HasEndTag   1
> >     UserTag foobar Interpolate 1
> >     UserTag foobar Order       foo bar baz
> >
> > You can also create "on the fly" tag arguments, like this:
> >
> >     UserTag foobar HasEndTag   1
> >     UserTag foobar Interpolate 1
> >     UserTag foobar AddAttr     1
> >     UserTag foobar Order       foo bar baz
> >
> > Your collection for the above should look like this:
> >
> >     my ($foo,$bar,$baz,$body,$opt) = @_;
> >
> > With AddAttr, you can pass an argument that's not in your "Order"
> > list and see it in your tag code, for instance:
> >
> >     [foobar foo="aaa" kevin="bbb"] Tag body [/foobar]
> >
> > In the above case, $foo will be "aaa", $bar and $baz will be undef.
> > $body will be " Tag body " and $opt->{kevin} will be "bbb".  Note that
> > $opt is a hashref.
> >
> > There are lots of other things you can do, but this article is probably
> > long enough for the moment. :-)
> >
> > --
> >    _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
> >   _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
> >  _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
> > _/   _/  _/_/_/_/      _/    _/_/_/  _/    _/
> > _______________________________________________
> > interchange-users mailing list
> > interchange-users at icdevgroup.org
> > http://www.icdevgroup.org/mailman/listinfo/interchange-users
> >
>
> Thank you! That was a great and useful reply :)
>
> Elver
>

   I would second that.  Very good explanation. If it isn't already in the
on-line docs then it should be added.  I do have a couple of questions.

This    UserTag foobar Order foo bar baz

begets this [foobar foo="aaa" bar="bbb" baz="ccc"]

The 'Order' is that literal ordering i.e. foo is first, bar is second, etc.
or is that another variable with a value as in Order number ?



This   UserTag foobar HasEndTag 1
allows grabbing body data in this form

[foobar foo="aaa" bar="bbb" baz="ccc"] Tag body [/foobar]
my ($foo,$bar,$baz,$body,$opt) = @_;

Is the variable $body specific  ?
In other words could $Body or $MyStuff be used in place $body ?

Is it because of adding 'HasEndTag 1' to the UserTag definition
that you can grab the 'Tag Body' information ?

Thank you
Jon





More information about the interchange-users mailing list