[ic] delimiter for tag parameters

Ron Phipps rphipps at reliant-solutions.com
Thu Oct 27 02:47:47 EDT 2005


> From: Kevin Walsh
> Sent: Wednesday, October 26, 2005 11:13 PM
> 
> 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.

Hey Kevin,

Sorry to have so much issue with understanding this.  I'm still confused
how the two differ.

We've determined that the following will result in incorrect syntax when
the title contains quotes:

[mytag title="[item-field title]"]

Why does the following not result in incorrect syntax:

[tmpn title][item-field title][/tmpn]
[mytag title="[scratch title]"]

Does Interchange handle [item-field title] and [scratch title]
differently?

Perhaps [item-field title] is simply replaced with its value and
[scratch title] actually passes it's value differently?

> >
> > [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.

I see, [tmp] and [tmpn] behave the same in this situation because we do
not want their values interpolated.  I'll switch them to [tmpn] for
better performance.

 
> > >
> > > 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) = @_;
> 
>         ...
>     }
>     EOR
> 
> The UserTag would make use of look for $Scratch->{$title} and
> $Scratch->{$description}.
> 
> 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. :-)

I really like this solution better.  Easy way to pass many parameters
without having to change the usertag parameter list and any place I call
the tag, just set the scratches and go.

Thanks again!
-Ron



More information about the interchange-users mailing list