File Coverage

blib/lib/Mason.pm
Criterion Covered Total %
statement 36 36 100.0
branch 2 4 50.0
condition 4 5 80.0
subroutine 10 10 100.0
pod n/a
total 52 55 94.5


line stmt bran cond sub pod time code
1             package Mason;
2             $Mason::VERSION = '2.23';
3 20     20   9080 use Mason::Interp;
  20         73  
  20         1218  
4 20     20   26185 use Mason::PluginManager;
  20         64  
  20         841  
5 20     20   127 use Mason::Util qw(can_load uniq);
  20         31  
  20         1098  
6 20     20   114 use Method::Signatures::Simple;
  20         30  
  20         115  
7 20     20   9303 use strict;
  20         37  
  20         657  
8 20     20   100 use warnings;
  20         30  
  20         583  
9              
10 20     20   6639 method new ($class: %params) {
  111     111   250  
  111         462  
  111         262  
11              
12             # Extract plugins and base_interp_class
13             #
14 111   100     936 my $plugin_specs = delete( $params{plugins} ) || [];
15 111   66     710 my $base_interp_class = delete( $params{base_interp_class} )
16             || $class->default_base_interp_class;
17              
18             # Process plugins and determine real interp_class
19             #
20 111         1030 my @plugins = Mason::PluginManager->process_top_plugin_specs($plugin_specs);
21 109         525 my $interp_class =
22             Mason::PluginManager->apply_plugins_to_class( $base_interp_class, 'Interp', \@plugins );
23              
24             # Create and return interp
25             #
26 109 50       473 die "cannot pass mason_root_class directly"
27             if exists( $params{mason_root_class} );
28 109         4459 return $interp_class->new(
29             mason_root_class => $class,
30             plugins => \@plugins,
31             %params
32             );
33             }
34              
35 20     20   9087 method default_base_interp_class ($class:) {
  110     110   341  
  110         232  
36 111         557 my @candidates =
37 110         593 map { join( '::', $_, 'Interp' ) } ( uniq( $class, 'Mason' ) );
38 110 50       273 my ($base_class) = grep { can_load($_) } @candidates
  111         403  
39             or die sprintf( "cannot load %s for interp", join( ', ', @candidates ) );
40 110         493 return $base_class;
41             }
42              
43             1;
44              
45             __END__
46              
47             =pod
48              
49             =head1 NAME
50              
51             Mason - Powerful, high-performance templating for the web and beyond
52              
53             =head1 SYNOPSIS
54              
55             foo.mc:
56             % my $name = "Mason";
57             Hello world! Welcome to <% $name %>.
58              
59             #!/usr/local/bin/perl
60             use Mason;
61             my $mason = Mason->new(comp_root => '...');
62             print $mason->run('/foo')->output;
63              
64             =head1 DESCRIPTION
65              
66             Mason is a powerful Perl-based templating system, designed to generate dynamic
67             content of all kinds.
68              
69             Unlike many templating systems, Mason does not attempt to invent an alternate,
70             "easier" syntax for templates. It provides a set of syntax and features
71             specific to template creation, but underneath it is still clearly and proudly
72             recognizable as Perl.
73              
74             Mason is most often used for generating web pages. It has a companion web
75             framework, L<Poet|Poet>, designed to take maximum advantage of its routing and
76             content generation features. It can also be used as the templating layer for
77             web frameworks such as L<Catalyst|Catalyst::View::Mason2> and
78             L<Dancer|Dancer::Template::Mason2>.
79              
80             All documentation is indexed at L<Mason::Manual>.
81              
82             The previous major version of Mason (1.x) is available under the name
83             L<HTML::Mason>.
84              
85             =head1 SUPPORT
86              
87             The mailing list is C<mason-users@lists.sourceforge.net>. You must be
88             subscribed to send a message. To subscribe, visit
89             L<https://lists.sourceforge.net/lists/listinfo/mason-users>.
90              
91             You can also visit us at C<#mason> on L<irc://irc.perl.org/#mason>.
92              
93             Bugs and feature requests will be tracked at RT:
94              
95             http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mason
96             bug-mason@rt.cpan.org
97              
98             The latest source code can be browsed and fetched at:
99              
100             http://github.com/jonswar/perl-mason
101             git clone git://github.com/jonswar/perl-mason.git
102              
103             The official Mason website is L<http://www.masonhq.com/>, however it contains
104             mostly information about L<Mason 1|HTML::Mason>. We're not sure what the future
105             of the website will be wrt Mason 2.
106              
107             =head1 ACKNOWLEDGEMENTS
108              
109             Thanks to Stevan Little and the L<Moose> team for the awesomeness of Moose,
110             which motivated me to create a second version of Mason years after I thought I
111             was done.
112              
113             Thanks to Tatsuhiko Miyagawa and the L<PSGI/Plack|http://plackperl.org/> team,
114             who freed me from ever worrying about server backends again.
115              
116             =head1 SEE ALSO
117              
118             L<HTML::Mason>
119              
120             =head1 AUTHOR
121              
122             Jonathan Swartz <swartz@pobox.com>
123              
124             =head1 COPYRIGHT AND LICENSE
125              
126             This software is copyright (c) 2012 by Jonathan Swartz.
127              
128             This is free software; you can redistribute it and/or modify it under
129             the same terms as the Perl 5 programming language system itself.
130              
131             =cut