|
Revision 6066, 0.7 kB
(checked in by mizzy, 5 years ago)
|
|
lang/perl/Text-Trac: initial import.
|
| Line | |
|---|
| 1 | package Text::Trac::Macro; |
|---|
| 2 | use strict; |
|---|
| 3 | use base qw(Text::Trac::InlineNode Class::Accessor::Fast); |
|---|
| 4 | use UNIVERSAL::require; |
|---|
| 5 | use Text::ParseWords qw(quotewords); |
|---|
| 6 | |
|---|
| 7 | __PACKAGE__->mk_accessors( 'pattern' ); |
|---|
| 8 | |
|---|
| 9 | sub new { |
|---|
| 10 | my $class = shift; |
|---|
| 11 | my $self = {}; |
|---|
| 12 | bless $self, $class; |
|---|
| 13 | return $self; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | sub parse { |
|---|
| 17 | my ( $self, $name, $args, $match ) = @_; |
|---|
| 18 | my $c = $self->{context}; |
|---|
| 19 | |
|---|
| 20 | my @args = quotewords( ',\s*', 0, $args ) if $args; |
|---|
| 21 | map { s/^\s+|\s+$//g } @args; |
|---|
| 22 | |
|---|
| 23 | foreach my $class ("Text::Trac::Macro::$name", $name) { |
|---|
| 24 | if ( $class->require ) { |
|---|
| 25 | $match = $class->process( $c, @args ) || ''; |
|---|
| 26 | last; |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | return $match; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | 1; |
|---|