/[Frey]/trunk/lib/Frey/View.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations)
Mon Jun 30 20:02:14 2008 UTC (15 years, 9 months ago) by dpavlin
File size: 1647 byte(s)
 r43@eeepy:  dpavlin | 2008-06-30 17:23:37 +0200
 if methods are fully qualified (defined by TD import_template)
 then call them directly

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 confess/;
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 sub method_link {
29 my ( $pkg,$method ) = @_;
30 my $url = "/$pkg/$method";
31 $url = $method if $method =~ m!^/!;
32 a {
33 { href is $url }
34 outs $method
35 }
36 }
37
38 sub package_methods {
39 my ( $pkg, $methods ) = @_;
40 confess "methods not ARRAY ",dump($methods) unless ref($methods) =~ m/^ARRAY/;
41 outs $pkg;
42 ul {
43 foreach my $method ( @{ $methods } ) {
44 li { method_link( $pkg, $method ) }
45 }
46 }
47 }
48
49 template 'package-methods' => sub {
50 my ( $self, $req, $package ) = @_;
51 $package ||= $req->param('package');
52 my $methods = Template::Declare->templates->{ $package } or die "no package $package\n";
53 package_methods( $package, $methods );
54 };
55
56 template 'templates' => sub {
57 h1 { 'Available templates' };
58 my $templates = Template::Declare->templates;
59 debug_dump( $templates );
60
61 ul {
62 foreach my $package ( keys %$templates ) {
63 li {
64 package_methods( $package, $templates->{$package} );
65 }
66 }
67 }
68 };
69
70 template 'classes' => sub {
71 my $self = shift;
72 h1 { 'All packages in image' };
73 my $f = Frey->new;
74 debug_dump( $f->classes );
75 };
76
77 template 'error' => sub {
78 my ( $self, $req, $error ) = @_;
79 $error ||= dump( caller(1) );
80 warn "## error: $error\n";
81 pre {
82 { class is 'error' }
83 outs( $error );
84 };
85 };
86
87 1;

  ViewVC Help
Powered by ViewVC 1.1.26