1HTML::Mason(3)        User Contributed Perl Documentation       HTML::Mason(3)
2
3
4

NAME

6       Mason - High-performance, dynamic web site authoring system
7

SYNOPSIS

9           PerlModule HTML::Mason::ApacheHandler
10
11           <Location />
12               SetHandler perl-script
13               PerlHandler HTML::Mason::ApacheHandler
14           </Location>
15

DESCRIPTION

17       Mason is a tool for building, serving and managing large web sites. Its
18       features make it an ideal backend for high load sites serving dynamic
19       content, such as online newspapers or database driven e-commerce sites.
20
21       Actually, Mason can be used to generate any sort of text, whether for a
22       web site or not.  But it was originally built for web sites and since
23       that's why most people are interested in it, that is the focus of this
24       documentation.
25
26       Mason's various pieces revolve around the notion of "components''. A
27       component is a mix of HTML, Perl, and special Mason commands, one
28       component per file. So-called "top-level" components represent entire
29       web-pages, while smaller components typically return HTML snippets for
30       embedding in top-level components. This object-like architecture
31       greatly simplifies site maintenance: change a shared component, and you
32       instantly changed all dependant pages that refer to it across a site
33       (or across many virtual sites).
34
35       Mason's component syntax lets designers separate a web page into
36       programmatic and design elements. This means the esoteric Perl bits can
37       be hidden near the bottom of a component, preloading simple variables
38       for use above in the HTML. In our own experience, this frees content
39       managers (i.e., non-programmers) to work on the layout without getting
40       mired in programming details. Techies, however, still enjoy the full
41       power of Perl.
42
43       Mason works by intercepting innocent-looking requests (say,
44       http://www.yoursite.com/index.html) and mapping them to requests for
45       Mason components.  Mason then compiles the component, runs it, and
46       feeds the output back to the client.
47
48       Consider this simple Mason component:
49
50           % my $noun = 'World';
51           Hello <% $noun %>!
52           How are ya?
53
54       The output of this component is:
55
56           Hello World!
57           How are ya?
58
59       In this component you see a mix of standard HTML and Mason elements.
60       The bare '%' prefixing the first line tells Mason that this is a line
61       of Perl code. One line below, the embedded <% ... %> tag gets replaced
62       with the return value of its contents, evaluated as a Perl expression.
63
64       Beyond this trivial example, components can also embed serious chunks
65       of Perl code (say, to pull records from a database). They can also call
66       other components, cache results for later reuse, and perform all the
67       tricks you expect from a regular Perl program.
68

INSTALLATION

70       Mason has been tested under Linux, FreeBSD, Solaris, HPUX, and Win32.
71       As an all-Perl solution, it should work on any machine that has working
72       versions of Perl 5.00503+, mod_perl, and the required CPAN modules.
73
74       Mason has a standard MakeMaker-driven installation. See the README file
75       for details.
76

CONFIGURING MASON

78       This section assumes that you are able to install and configure a
79       mod_perl server. Relevant documentation is available at
80       http://www.apache.org (Apache) and http://perl.apache.org (mod_perl).
81       The mod_perl mailing list, archive, and guide are also great resources.
82
83       The simplest configuration of Mason requires a few lines in your
84       httpd.conf:
85
86           PerlModule HTML::Mason::ApacheHandler
87
88           <Location />
89               SetHandler perl-script
90               PerlHandler HTML::Mason::ApacheHandler
91           </Location>
92
93       The PerlModule directive simply ensures that the Mason code is loaded
94       in the parent process before forking, which can save some memory when
95       running mod_perl.
96
97       The <Location> section routes all requests to the Mason handler, which
98       is a simple way to try out Mason. A more refined setup is discussed in
99       the Controlling Access via Filename Extension section of the
100       administrator's manual.
101
102       Once you have added the configuration directives, restart the server.
103       First, go to a standard URL on your site to make sure you haven't
104       broken anything. If all goes well you should see the same page as
105       before. If not, recheck your Apache config files and also tail your
106       server's error log.
107
108       If you are getting "404 Not Found" errors even when the files clearly
109       exist, Mason may be having trouble with your document root. One
110       situation that will unfortunately confuse Mason is if your document
111       root goes through a symbolic link. Try expressing your document root in
112       terms of the true filesystem path.
113
114       Next, try adding the tag <% 2+2 %> at the top of some HTML file. If you
115       reload this page and see a "4", Mason is working!
116

DOCUMENTATION ROADMAP

118       Once Mason is on its feet, the next step is to write a component or
119       two. The Mason Developer's Manual is a complete tutorial for writing,
120       using, and debugging components. A reference companion to the
121       Developer's Manual is the Request API documentation,
122       HTML::Mason::Request.
123
124       Whoever is responsible for setting up and tuning Mason should read the
125       Administrator's Manual, though developers will also benefit from
126       reading it as well. This document covers more advanced configuration
127       scenarios and performance optimization. The reference companion to the
128       Administrator's manual is the Parameters Reference, which describes all
129       the parameters you can use to configure Mason.
130
131       Most of this documentation assumes that you're running Mason on top of
132       mod_perl, since that is the most common configuration.  If you would
133       like to run Mason via a CGI script, refer to the
134       HTML::Mason::CGIHandler documentation.  If you are using Mason from a
135       standalone program, refer to the Using Mason from a Standalone Script
136       section of the administrator's manual.
137
138       There is also a book about Mason, Embedding Perl in HTML with Mason, by
139       Dave Rolsky and Ken Williams, published by O'Reilly and Associates.
140       The book's website is at http://www.masonbook.com/.  This book goes
141       into detail on a number of topics, and includes a chapter of recipes as
142       well as a sample Mason-based website.
143

AUTHORS

145       Jonathan Swartz <swartz@pobox.com>, Dave Rolsky <autarch@urth.org>, Ken
146       Williams <ken@mathforum.org>, John Williams <williams@tni.com>
147
149       Copyright (c) 1998-2005 Jonathan Swartz.  All rights reserved.  This
150       program is free software; you can redistribute it and/or modify it
151       under the same terms as Perl itself.
152
153       The full text of the license can be found in the LICENSE file included
154       with this module.
155

SEE ALSO

157       HTML::Mason::Devel, HTML::Mason::Admin
158
159
160
161perl v5.12.0                      2010-05-03                    HTML::Mason(3)
Impressum