1 |
package Frey::View; |
2 |
|
3 |
use strict; |
4 |
use warnings; |
5 |
|
6 |
use Template::Declare::Tags; # defaults to 'HTML' |
7 |
use Frey; |
8 |
use base qw/Template::Declare/; |
9 |
use Data::Dump qw/dump/; |
10 |
use Carp qw/carp/; |
11 |
|
12 |
sub debug_dump { |
13 |
my $dump = dump( @_ ); |
14 |
carp "debug_dump $dump\n"; |
15 |
pre { |
16 |
{ class is 'debug' } |
17 |
outs $dump; |
18 |
} |
19 |
} |
20 |
|
21 |
template 'status' => sub { |
22 |
my ( $self ) = @_; |
23 |
p { 'Welcome to Frey' } |
24 |
show( 'templates' ); |
25 |
show( 'classes' ); |
26 |
}; |
27 |
|
28 |
template 'templates' => sub { |
29 |
h1 { 'Available templates' }; |
30 |
my $templates = Template::Declare->templates; |
31 |
debug_dump( $templates ); |
32 |
ul { |
33 |
foreach my $pkg ( keys %$templates ) { |
34 |
li { |
35 |
outs $pkg; |
36 |
ul { |
37 |
foreach my $template ( @{ $templates->{$pkg} } ) { |
38 |
li { |
39 |
a { |
40 |
{ href is "/$pkg/$template" } |
41 |
$template |
42 |
} |
43 |
} |
44 |
} |
45 |
} |
46 |
} |
47 |
} |
48 |
} |
49 |
}; |
50 |
|
51 |
template 'classes' => sub { |
52 |
my $self = shift; |
53 |
h1 { 'All classes in image' }; |
54 |
my $f = Frey->new; |
55 |
debug_dump( $f->classes ); |
56 |
}; |
57 |
|
58 |
template 'error' => sub { |
59 |
my $self = shift; |
60 |
p { |
61 |
{ class is 'error' } |
62 |
outs( @_ ); |
63 |
} |
64 |
}; |
65 |
|
66 |
1; |