line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::View::XML::Simple; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22827
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.022'; |
5
|
|
|
|
|
|
|
use 5.008_001; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends qw(Catalyst::View); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub process { |
11
|
|
|
|
|
|
|
my($self, $c, $stash_key) = @_; |
12
|
|
|
|
|
|
|
use XML::Simple; |
13
|
|
|
|
|
|
|
my $xs = XML::Simple->new(); |
14
|
|
|
|
|
|
|
my $output; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $data = { map { ($_ => $c->stash->{$_}) } |
17
|
|
|
|
|
|
|
keys %{$c->stash} }; |
18
|
|
|
|
|
|
|
eval { |
19
|
|
|
|
|
|
|
$output = $xs->XMLout($data); |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
return $@ if $@; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$c->res->output($output); |
24
|
|
|
|
|
|
|
return 1; # important |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Catalyst::View::XML::Simple - XML view for your data |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# lib/MyApp/View/XML.pm |
39
|
|
|
|
|
|
|
package MyApp::View::XML::Simple; |
40
|
|
|
|
|
|
|
use base qw( Catalyst::View::XML::Simple ); |
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub hello : Local { |
44
|
|
|
|
|
|
|
my($self, $c) = @_; |
45
|
|
|
|
|
|
|
$c->stash->{message} = 'Hello World!'; |
46
|
|
|
|
|
|
|
$c->forward('View::XML::Simple'); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Catalyst::View::XML::Simple is a Catalyst View handler that returns stash |
52
|
|
|
|
|
|
|
data in XML format using XML::Simple. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Lindolfo 'Lorn' Rodrigues E<lt>lorn at cpan.orgE<gt> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 LICENSE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
62
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 Thanks |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Thanks do Tatsuhiko Miyagawa for Catalyst::View::JSON :) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |