Mason doesn’t aim to be the one true Perl-based templating system for building web sites, but it’s led many programmers to abandon their custom solutions when they’ve seen how much easier using Mason can be. It’s a powerful, open source, Perl-based web site development and delivery engine, with features that make it an ideal backend for high load sites serving dynamic content. Mason uses a concept called components: a mix of HTML, Perl, and special Mason commands. These components can be entire web pages, or bits of HTML that can be embedded in top-level components. Shared and reusable, these components greatly simplify site maintenance: when you change a shared component, you instantly change all pages that refer to it.Although using Mason isn’t difficult, creating a Mason-based site can be tricky. Embedding Perl in HTML with Mason, written by members of Mason’s core development team, shows you how to take advantage of Mason’s strengths while avoiding the obstacles that inexperienced users may encounter. Mason’s unique features, when used properly, can streamline the design of a web site or application. This concise book covers these features from several angles, and includes a study of the authors’ sample site where these features are used.Embedding Perl in HTML with Mason shows you how to create large, complex, dynamically driven web sites that look good and are a snap to maintain. You’ll learn how to visualize multiple Mason-based solutions to any given problem and select among them. The book covers the latest line of Mason development 1.1x, which has many new features, including line number reporting based on source files, sub-requests, and easier use as a CGI. The only book to cover this important tool, Embedding Perl in HTML with Mason is essential reading for any Perl programmer who wants to simplify web site design. Learn how to use Mason, and you’ll spend more time making things work, and less time reinventing the wheel.

About the Author
is a programmer, author, and activist with a background in music composition and an obsession with Hong Kong films and the works of author Gene Wolfe. He has been actively developing Free (Perl) Software for several years and is a member of the Mason core development team. For more information about Embedding Perl in HTML with Mason please visit www.masonbook.com, a web site maintained by the authors where additional information and downloadable source code are available.

is a researcher in Document Categorization at the University of Sydney in Australia. He has written many Perl modules of varying utility, about 20 of which are available on CPAN. Like co-author Dave Rolsky, Ken is a member of the HTML::Mason core development team. His educational background is in mathematics and music. For more information about Embedding Perl in HTML with Mason please visit www.masonbook.com, a web site maintained by the authors where additional information and downloadable source code are available.

Excerpt. © Reprinted by permission. All rights reserved.
CHAPTER 5 – Advanced Features

In the previous chapters you have been introduced to the basic features of Mason, and you should have a fairly good idea by now of how you might actually go about constructing a dynamic web site from Mason components. You have seen a few of Mason ’s unique features, such as the autohandler mechanism, the dhandler mechanism, and the ability to pass arbitrary data between components. In this chapter we’ll go beyond the basics and learn more about advanced ways to use Mason components to design large dynamic sites. You’ll learn how to define multiple components in the same text file, how to create components on the fly from Perl strings, how to manage multiple component root directories, and (finally!)how to use all of Mason’s object-oriented features.

Subcomponents
Although we often imagine a one-to-one correspondence between text files and Mason components, it is actually possible to define multiple components in a single text file. This is achieved by using a block, a special Mason directive that defines one component from within another. The component embedded within the block is called a subcomponent, and it is visible only to the component within which it resides:component A may not access component B ’s subcomponents directly.

下载地址:

9780596002251.epub
9780596002251.pdf

Embedding Perl in HTML with Mason

发表评论

电子邮件地址不会被公开。 必填项已用*标注