Embedding Perl in HTML with Mason
Download : Embedding Perl in HTML with Mason
Mason is a tool for embedding the Perl programming language into text, in order to create text dynamically, most often in HTML. But Mason does not simply stop at HTML. It can just as easily create XML, WML, POD, configuration files, or the complete works of Shakespeare.
Table of Contents
Foreword
Preface
Intended Audience
Requirements
How to Read This Book
Overview
Other Resources
Typographic Conventions
We'd Like to Hear from You
Open Publication License
Acknowledgments
Chapter 1: Introduction
A First Example
The Main Features of Mason
Components: Modular Design Elements
Object-Style Component Inheritance
Intelligent Caching Mechanisms
Integration with Apache and mod_perl
Alternatives to Mason
Embperl
Apache::ASP
HTML::Template
Text::Template
Template Toolkit
PHP
Philosophy
Getting Started with Mason
A Standalone Installation
A mod_perl Installation
Trying It Out
Chapter 2: Components
Mason from 10,000 Feet
Core Concepts
Basic Component Syntax
Substitution Tags: <% %>
Embedded Perl: % Lines and <%perl> Blocks
Calling Other Components: <& &> Tags
Other Named Blocks
Escaping a Newline
Component Arguments
<%args> Block Revisited
%ARGS
%ARGS Versus @_
Argument Examples
Arguments via Component Calls
Arguments via HTTP Requests
Component Return Values
Special Globals
$m
$r
Sample Component
Chapter 3: Special Components: Dhandlers and Autohandlers
Dhandlers
Finer Control over Dhandlers
Dhandlers and Apache Configuration
Autohandlers
Using Autohandlers for Initialization
Using Autohandlers as Filters
Inspecting the Wrapping Chain
Using Autohandlers and Dhandlers Together
Chapter 4: APIs
Request Class and Object API
Constructor Parameters
Calling Other Components
Aborting the Flow of Execution
The Wrapping Chain
Dhandler-Related Methods
Miscellaneous Methods
Introspection
Buffer-Related Methods
Caching
Subrequests
Methods Available Only When Using ApacheHandler
Methods Available When Using ApacheHandler or CGIHandler
Getting in Close with Buffers
Component Object API
Methods for File-based Components
Buffers
Chapter 5: Advanced Features
Subcomponents
Creating Components on the Fly
Sharing Data Among Component Sections
Methods and Attributes
Methods
Using Methods for Titles and Headers
Methods with Dynamic Content
Attributes
Top-Down Versus Bottom-Up Inheritance
Calling Components with Content Blocks
Advanced Inheritance
Inheritance and Multiple Component Roots
An Advanced Inheritance Example
Subrequests
A Caution About Autohandler Inheritance
Chapter 6: The Lexer, Compiler, Resolver, and Interpreter Objects
Passing Parameters to Mason Classes
The Lexer
The Compiler
Altering Every Component's Content
Compiler Methods
The Resolver
The Interpreter
Request Parameters Passed to the Interpreter
Chapter 7: Using Mason with mod_perl
Configuring Mason
Configuration via httpd.conf
Configuration via Custom Code
Document Root Versus the Component Root
Not OK
$r
ApacheHandler Parameters
To Autoflush or Not to Autoflush
Generating Something Besides HTML
Apache::Status and Mason
Chapter 8: Building a Mason Site
Functionality
Directory Layout
File Extensions
Apache Configuration
The Components
The Unrestricted Parts
Components with Access Controls
All Done
Further Directions
Chapter 9: Mason and CGI
CGI-Appropriate Situations
CGI-Inappropriate Situations
Creating a CGI-Based Site in Mason
Using Mason Templates Inside Regular CGI Scripts
Design Considerations
Differences Between Mason Under CGI and mod_perl
Chapter 10: Scalable Design
Modules Versus Components
The Other Side
Components as Independent Units
Component Layout
File Naming and Directory Layout
Random Advice
Chapter 11: Recipes
Sessions
Without Touching httpd.conf
Predeclaring the Global via an httpd.conf File
Predeclaring the Global via a handler.pl Script
Using Cache::Cache for Sessions
Putting the Session ID in the URL
Making Use of Autoflush
User Authentication and Authorization
Using Apache::AuthCookie
Authentication Without Cookies
Access Controls with Attributes
Co-Branding Color Schemes
With Stylesheets
With Code
Developer Environments
Multiple Component Roots
Multiple Server Configurations
Managing DBI Connections
Using Mason Outside of Dynamic Web Sites
Generating a Static Site from Components
Generating Config Files
Chapter 12: Custom Mason Subclasses
Class::Container as a Superclass
Syntax: Your Very Own Lexer
Output: Compiling to a Different Output
Storage: Replacing the Resolver
Request: A Request Object with a Built-in Session
Argument Munging: ApacheHandler
More Reader Exercises
Appendix A: The Mason API
Interpreter
Object Properties
Directories
Runtime Methods
Request
Object Properties
Altering the Request Flow
Caching
Introspection
Content and Output
Fetching/Running Components
Subrequests
Component
Object Properties
Component Relationships
Inheritance
Resolver
ApacheHandler
CGIHandler
Compiler
Object Properties
Compilation Callbacks
Lexer
Appendix B: Object Constructor Parameters
HTML::Mason::Interp
HTML::Mason::Request
HTML::Mason::Resolver::File
HTML::Mason::ApacheHandler
HTML::Mason::Compiler
HTML::Mason::Component
HTML::Mason::Buffer
HTML::Mason::CGIHandler
HTML::Mason::Lexer
Appendix C: Text Editors That Understand Mason
Emacs
Vim
Appendix D: Content Management with Bricolage
Installing Bricolage
Elements: the Building Blocks of Content
Content Editing
Templates
Where to Learn More
Glossary
Colophon
Copyright
Download : Embedding Perl in HTML with Mason
0 komentar:
Posting Komentar