1 |
package Frey::Web::Links; |
2 |
use Moose; |
3 |
|
4 |
=head1 NAME |
5 |
|
6 |
Frey::Web::Links - simple links to current page with one param |
7 |
|
8 |
=cut |
9 |
|
10 |
has 'name' => ( |
11 |
'is' => 'rw', |
12 |
isa => 'Str', |
13 |
required => 1, |
14 |
); |
15 |
|
16 |
has 'current' => ( |
17 |
is => 'rw', |
18 |
isa => 'Str', |
19 |
required => 1, |
20 |
); |
21 |
|
22 |
has 'values' => ( |
23 |
is => 'rw', |
24 |
isa => 'ArrayRef[Str]', |
25 |
required => 1, |
26 |
); |
27 |
|
28 |
has 'current_tag' => ( |
29 |
is => 'rw', |
30 |
isa => 'Str', |
31 |
default => 'em', |
32 |
); |
33 |
|
34 |
has 'delimiter' => ( |
35 |
is => 'rw', |
36 |
isa => 'Str', |
37 |
default => ' ', |
38 |
); |
39 |
|
40 |
sub links { |
41 |
my $self = shift; |
42 |
my @out = |
43 |
map { |
44 |
if ( $self->current eq $_ ) { |
45 |
'<' . $self->current_tag . '>' . $_ . '</' . $self->current_tag . '>' |
46 |
} else { |
47 |
qq|<a href="?| . $self->name . qq|=$_">$_</a>| |
48 |
} |
49 |
} ( @{ $self->values } ); |
50 |
return @out if wantarray; |
51 |
return join($self->delimiter, @out); |
52 |
} |
53 |
|
54 |
1; |