1 |
package View; |
package Frey::View; |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
use Template::Declare::Tags; # defaults to 'HTML' |
use Template::Declare::Tags; # defaults to 'HTML' |
7 |
use base 'Template::Declare'; |
use Frey; |
8 |
|
use base qw/Template::Declare/; |
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
|
use Carp qw/carp/; |
11 |
|
|
12 |
use Strix::User; |
sub debug_dump { |
13 |
my $user = Strix::User->new( nick => 'dpavlin' ); |
my $dump = dump( @_ ); |
14 |
|
carp "debug_dump $dump\n"; |
15 |
|
pre { |
16 |
|
{ class is 'debug' } |
17 |
|
outs $dump; |
18 |
|
} |
19 |
|
} |
20 |
|
|
21 |
template user => sub { |
template 'status' => sub { |
22 |
html { |
my ( $self ) = @_; |
23 |
head {} |
p { 'Welcome to Frey' } |
24 |
body { |
show( 'templates' ); |
25 |
p {'Hello, world wide web!'} |
show( 'classes' ); |
26 |
pre { |
}; |
27 |
outs dump( $user ); |
|
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; |
1; |