GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mason::Manual::Setup(3) User Contributed Perl Documentation Mason::Manual::Setup(3)

Mason::Manual::Setup - Setting up Mason

The most common use of Mason is to generate dynamic web content.

Poet is a web framework designed specifically to work with Mason. Given an HTTP request, Poet generates a corresponding Mason request, and uses the output from Mason to form the HTTP response. Poet takes care of the web development details that are outside of Mason's domain, such as server integration and configuration. Poet::Manual::Tutorial shows how to set up a Poet/Mason site in great detail.

Mason can also be used in the popular web frameworks Catalyst and Dancer, as a drop-in replacement for their default template engines. See Catalyst::View::Mason2 and Dancer::Template::Mason2.

Mason can be used to generate any kind of dynamic content. I have personally used it to generate Apache configuration files, emails, and C++ code.

To use Mason from a script or library, use the Mason::Interp API:

    my $interp = Mason->new(
        comp_root => '/path/to/comps',
        data_dir  => '/path/to/data',
        ...
    );
    my $output = $interp->run( '/request/path', foo => 5 )->output();

If you want to process a directory with a mix of Mason templates and static files, check out Any::Template::ProcessDir.

To try out Mason syntax from the command line, use the mason script:

    % mason
    2 + 2 = <% 2+2 %>
    ^D
    2 + 2 = 4

Mason uses Log::Any to log various events, such as the start and end of each request. You can direct thesse logs to the output of your choice; see Log::Any::Adapter. If you don't specify anything then the logs will go into the void.

Mason

Jonathan Swartz <swartz@pobox.com>

This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2015-05-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.