| 1 | package Embperl::Syntax::Test2; | ||
| 2 | |||
| 3 | use Embperl::Syntax qw{:types} ; | ||
| 4 | use Embperl::Syntax::HTML ; | ||
| 5 | use File::Spec::Unix; | ||
| 6 | |||
| 7 | # We inherit the generic HTML support from Embperl::Syntax::HTML | ||
| 8 | use vars qw(@ISA); | ||
| 9 | @ISA = qw(Embperl::Syntax::HTML) ; | ||
| 10 | |||
| 11 | sub new { | ||
| 12 | my $class = shift; | ||
| 13 | my $self = Embperl::Syntax::HTML::new($class); | ||
| 14 | |||
| 15 | # initialise ourselves when an object is created if it hasn't | ||
| 16 | # been done already | ||
| 17 | if (!$self->{-randomInit}) { | ||
| 18 | $self->{-randomInit} = 1; | ||
| 19 | init($self); | ||
| 20 | } | ||
| 21 | return $self; | ||
| 22 | } | ||
| 23 | |||
| 24 | # initialise things and define our new syntax handling | ||
| 25 | sub init { | ||
| 26 | my $self = shift; | ||
| 27 | |||
| 28 | # redefine the tags we want to manipulate attributes for | ||
| 29 | $self->AddTag('qq', ['href'], undef, undef, { | ||
| 30 | perlcode => q[ { | ||
| 31 | # _ep_sa is an apparently undocumented function which | ||
| 32 | # allows you to rewrite an attribute of the current node | ||
| 33 | # specified by %$n% | ||
| 34 | _ep_sa(%$n%, 'href', Embperl::Syntax::Test2::rewrite_url(%&'href%)); | ||
| 35 | }], | ||
| 36 | }); | ||
| 37 | |||
| 38 | $self->AddTag('a', ['href'], undef, undef, { | ||
| 39 | perlcode => q[ { | ||
| 40 | # _ep_sa is an apparently undocumented function which | ||
| 41 | # allows you to rewrite an attribute of the current node | ||
| 42 | # specified by %$n% | ||
| 43 | _ep_sa(%$n%, 'href', Embperl::Syntax::Test2::rewrite_url(%&'href%)); | ||
| 44 | }], | ||
| 45 | |||
| 46 | }); | ||
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | sub rewrite_url | ||
| 51 | { | ||
| 52 | warn "rewrite_url got $_[0]\n" ; | ||
| 53 | return "**$_[0]**12**"; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1 ; |