My personal feeling about XMLSubs is that it should
take the code out of the HTML to some perl library.
So to use an XMLSub with perl expression as the args
to the tag though possible is not what I would recommend.

To do what you want below, I would recommend having all 
of the logic in the perl subroutine, and just use the 
tag everywhere.  Without all that conditional logic.
For example, you say you want something like:

> <My:tag_it condition="$Response->{UserName} eq 'Joshua'"
>     start_tag='<b>' end_tag='</b>'>
>   ..some HTML here...
> </My:tag_it>             [Stupid example, but I hope you get the idea]
> 

How I might do this is 

<my:tagit user='Joshua' tag='b'>
  ..some HTML here...
</my:tagit>

Then the perl sub might be like:

sub my::tagit {
  my($args, $html) = @_;
  if($args->{user} eq $Session->{UserName}) {
     print "<$args->{tag}>$html</$args->{tag}>";
  } else {
     print $html;
  }
}

The point here is to dumb down your HTML/XML constructs.
Otherwise you would probably want to just stick with normal
<% ASP code blocks %>

--Joshua


Henrik Tougaard wrote:
> 
> Joshua Chamas wrote:
> >
> > I think > is just about the only thing that you can't use as
> > a character in the attributes for an XMLSubs and that's because
> > it gets parsed with an aggressive ( or stupid ;) regexp like:
> >
> >       $$data =~ s|\<\s*($self->{xml_subs_match})([^\>]*)/\>
> 
> Pity!
> I would like to use XMLSubs to capture some HTML-output and do
> postprocess them accoring to the attributes.
> 
> Eg. if $Response->{UserName} is "Joshua" then bold part of the page.
> It could be done something like this:
> 
> <My:tag_it condition="$Response->{UserName} eq 'Joshua'"
>     start_tag='<b>' end_tag='</b>'>
>   ..some HTML here...
> </My:tag_it>             [Stupid example, but I hope you get the idea]
> 
> OK the tags are out. I can handle that by making an XMLSub
> for every tag-pair that I need, or whatever...
> But it is a pian to have to say:
> 
> <% $svtwnbu=$Response->{UserName} eq 'Joshua', %>
> <My:bold_it condition=$sbtwnbu>
>    ...more HTML here...
> </My:bold_it>
> 
> [Where $svtwnbu is some-variable-that-will-never-be-used elsewhere :-]
> 
> Not so neat.
> 
> Is there a simpler way of doing this?
> 
> ---
> Henrik Tougaard, FOA, Denmark.

Reply via email to