| 1 | package Mojo::Debugbar::Monitor::Template; | ||||||||||
| 2 | 1 | ▶ | use Mojo::Base "Mojo::Debugbar::Monitor"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | has 'icon' => '<i class="icon-file-code"></i>'; | |||||||||
| 5 | 1 | has 'name' => 'Templates'; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | =head2 render | ||||||||||
| 9 | |||||||||||
| 10 | Returns the html | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub render { | ||||||||
|
Subroutine
render: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 15 | 0 | my $self = shift; | |||||||||
| 16 | |||||||||||
| 17 | 0 | return sprintf( | |||||||||
| 18 | '<table class="debugbar-templates table" data-debugbar-ref="%s"> | ||||||||||
| 19 | <thead> | ||||||||||
| 20 | <tr><th>Path</th></tr> | ||||||||||
| 21 | </thead> | ||||||||||
| 22 | <tbody> | ||||||||||
| 23 | %s | ||||||||||
| 24 | </tbody> | ||||||||||
| 25 | </table>', | ||||||||||
| 26 | ref($self), $self->rows | ||||||||||
| 27 | ); | ||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | =head2 rows | ||||||||||
| 31 | |||||||||||
| 32 | Build the rows | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub rows { | ||||||||
|
Subroutine
rows: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | |||||||||||
| 39 | 0 | my $time = time; | |||||||||
| 40 | 0 | my ($sec, $min, $hour) = localtime($time); | |||||||||
| 41 | 0 | my $rows = sprintf('<tr><td>Templates at %s:%s:%s (%s)</td></tr>', $hour, $min, $sec, scalar @{ $self->items }); | |||||||||
| 42 | |||||||||||
| 43 | 0 | foreach my $template (@{ $self->items }) { | |||||||||
| 44 | 0 | $rows .= sprintf('<tr><td>templates/%s.html.ep</td></tr>', $template); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | return $rows; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | =head2 start | ||||||||||
| 51 | Listen for "before_render" event and store template names | ||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub start { | ||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | 0 | my $self = shift; | |||||||||
| 56 | |||||||||||
| 57 | 0 | my @templates; | |||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | $self->app->hook(before_render => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 60 | 0 | my ($c, $args) = @_; | |||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | push(@templates, $args->{ template }) if ($args->{ template }); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | }); | |||||||||
| 64 | |||||||||||
| 65 | 0 | $self->items(\@templates); | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||