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