[ic] delimiter for tag parameters

Kevin Walsh kevin at cursor.biz
Thu Oct 27 02:12:35 EDT 2005

Ron Phipps [rphipps at reliant-solutions.com] wrote:
> > The order of interpolation wouldn't make a difference whether you were
> > doing this: 
> > 
> >     [mytag title="[item-field title]"]
> > 
> > or this:
> > 
> >     [tmpn tmp][item-field title][/tmpn]
> >     [mytag title="[scratch tmp]"]
> > 
> > Both cases involve the replacement of the [item-field] marker, followed
> > by the interpolation of the real Interchange tags.
> > 
> > Your problem was caused by the [item-field] marker's replacement value
> > causing a syntax error with the subsequent tag interpolation.  That
> > won't happen with the above (body text) technique.
> >
> I'm still a bit confused.  I understand why there was a problem with:
> [mytag title="[item-field title]"]
> However I do not understand why this fixes it and how it differs in IC's
> eyes: 
As you noted, when [item-field title] gets replaced with the actual
value, the resulting syntax could be incorrect if the value contains
quotes.  I.e. you could end up with this, after replacement:

    [mytag title="Kevin says "hello""]

Using the suggested solution, you would end up with this:

    [tmpn tmp]Kevin says "hello"[/tmpn]

That's much safer, syntax-wise.

> [tmp title][item-field title][/tmp]
> [mytag title="[scratch title]"]
> Also your original example used [tmp title] and your most recent example
> uses [tmpn title], both seem to work properly, is one preferred over the
> other? 
[tmp] will interpolate its tag body, whereas [tmpn] will not.  That's
much the same as the difference between [set] (no interpolation) and
[seti] (interpolates its body text).

In the above example, the [item-field] is just a (sub-tag) token that
will be replaced, rather than interpolated, so no further interpolation
is required.  Using [tmpn] will therefore save a couple of ms in your
page parse time.

> >
> > Another poster suggested that you modify your [mytag] to become a
> > container and then pass [item-field title] directly as your tag's body
> > text.  That will work too, and would be more efficient than my [tmpn]
> > suggestion. 
> > 
> > In case you missed it, the poster's suggestion was to modify your
> > UserTag to allow this: 
> > 
> >     [mytag][item-field title][/mytag]
> >
> If I went this route then I would need to parse the parameters contained
> within the body, since I will be passing more then one field.  Which
> would be more efficient writing a parse routine for the  body text, or
> using the [tmp] setting? 
If you're passing more than one parameter then you clearly can't
use the single tag body for that purpose.  In that case, you will
need to use multiple temporary scratches and either pass in the
[scratch tmp] value, or pass in the scratch name.  If you pass in
the scratch name then you'll be able to use $Scratch->{whatever} in
your UserTag.  That would be even more efficient, as it would give
Interchange one less tag to interpolate on your page.  For instance:

    [tmpn mytag_title][item-field title][/tmpn]
    [tmpn mytag_description][item-description][/tmpn]
    [mytag title="mytag_title" description="mytag_description"]

Your UserTag can then get at the scratch values like this:

    UserTag mytag Order title description
    UserTag mytag Routine <<EOR
    sub {
        my ($title,$description) = @_;


The UserTag would make use of look for $Scratch->{$title} and

You could make it even simpler (and a little scarier) by just passing
in the prefix, like this:

    [tmpn mytag_title][item-field title][/tmpn]
    [tmpn mytag_description][item-description][/tmpn]
    [mytag prefix="mytag"]

Your UserTag would then use something like $Scratch->{"${prefix}_title"}
to get at the scratchpad values.

I hope some of that makes sense. :-)

   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/

More information about the interchange-users mailing list