| 1 | package HTML::Latemp::NavLinks::GenHtml::Text; | ||
| 2 | 1 | $HTML::Latemp::NavLinks::GenHtml::Text::VERSION = '0.2.8'; | |
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use vars qw($nav_buttons_html); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | ▶ | use parent 'HTML::Latemp::NavLinks::GenHtml'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | |||
| 11 | 1 | __PACKAGE__->mk_accessors( | |
| 12 | qw( | ||
| 13 | nav_links | ||
| 14 | root | ||
| 15 | ) | ||
| 16 | ); | ||
| 17 | |||
| 18 | 1 | ▶ | use Template; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | # load Template::Stash to make method tables visible | ||
| 21 | 1 | ▶ | use Template::Stash; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | |||
| 23 | # Define a method to return a substring. | ||
| 24 | $Template::Stash::SCALAR_OPS->{'substr'} = sub { | ||
| 25 | 0 | ▶ | return substr( $_[0], $_[1], $_[2] ); |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 26 | 1 | }; | |
| 27 | |||
| 28 | sub _get_nav_buttons_html | ||
| 29 | { | ||
| 30 | 0 | ▶ | my $self = shift; |
|
Subroutine
_get_nav_buttons_html: not called CC=1 SCAR=6.9
| |||
| 31 | |||
| 32 | 0 | my (%args) = (@_); | |
| 33 | |||
| 34 | 0 | my $with_accesskey = $args{'with_accesskey'}; | |
| 35 | |||
| 36 | 0 | my $root = $self->root(); | |
| 37 | |||
| 38 | 0 | my $template = Template->new( | |
| 39 | { | ||
| 40 | 'POST_CHOMP' => 1, | ||
| 41 | } | ||
| 42 | ); | ||
| 43 | |||
| 44 | 0 | my $vars = { | |
| 45 | 'buttons' => $self->_get_buttons(), | ||
| 46 | 'root' => $root, | ||
| 47 | 'with_accesskey' => $with_accesskey, | ||
| 48 | }; | ||
| 49 | |||
| 50 | 0 | my $nav_links_template = <<'EOF'; | |
| 51 | [% USE HTML %] | ||
| 52 | [% FOREACH b = buttons %] | ||
| 53 | [% SET key = b.dir.substr(0, 1) %] | ||
| 54 | <li>[ | ||
| 55 | [% IF b.exists %] | ||
| 56 | <a href="[% HTML.escape(b.link_obj.direct_url()) %]" title="[% b.title %] (Alt+[% key FILTER upper %])" | ||
| 57 | [% IF with_accesskey %] | ||
| 58 | accesskey="[% key %]" | ||
| 59 | [% END %] | ||
| 60 | >[% END %] [% b.dir %] [% IF b.exists %]</a> | ||
| 61 | [% END %] | ||
| 62 | ]</li> | ||
| 63 | [% END %] | ||
| 64 | EOF | ||
| 65 | |||
| 66 | 0 | my $nav_buttons_html = ""; | |
| 67 | |||
| 68 | 0 | $template->process( \$nav_links_template, $vars, \$nav_buttons_html ); | |
| 69 | 0 | return $nav_buttons_html; | |
| 70 | } | ||
| 71 | |||
| 72 | sub get_total_html | ||
| 73 | { | ||
| 74 | 0 | ▶ | my $self = shift; |
|
Subroutine
get_total_html: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 75 | |||
| 76 | return | ||
| 77 | 0 | "<ul class=\"nav_links\">\n" | |
| 78 | . $self->_get_nav_buttons_html(@_) | ||
| 79 | . "\n</ul>"; | ||
| 80 | } | ||
| 81 | |||
| 82 | 1 | 1; | |
| 83 | |||
| 84 | __END__ | ||