|
NAMEText::MicroMason::Filters - Add Output Filters like "|h" and "|u"SYNOPSISInstead of using this class directly, pass its name to be mixed in:use Text::MicroMason; my $mason = Text::MicroMason->new( -Filters ); Use the standard compile and execute methods to parse and evaluate templates: print $mason->compile( text=>$template )->( @%args ); print $mason->execute( text=>$template, @args ); Enables filtering of template expressions using syntax similar to that available in HTML::Mason v1: <%args> $name </%args> Welcome, <% $name |h %>! <a href="more.masn?name=<% $name |u %>">Click for More</a> You can set default filters, and shut them off using the "n" flag: my $mason = Text::MicroMason->new( -Filters, default_filters => 'h' ); <%args> $name </%args> Welcome, <% $name %>! <a href="more.masn?name=<% $name |nu %>">Click for More</a> You can tell MicroMason to always override default filters instead of combining them: my $mason = Text::MicroMason->new( -Filters, default_filters => 'h', default_policy => 'override' ); <%args> $name </%args> Welcome, <% $name %>! <a href="more.masn?name=<% $name |u %>">Click for More</a> You can define additional filters and stack them: my $mason = Text::MicroMason->new( -Filters ); $mason->filter_functions( myfilter => \&function ); $mason->filter_functions( uc => sub { return uc( shift ) } ); <%args> $name </%args> Welcome, <% $name |uc,myfilter %>! DESCRIPTIONThis module enables the filtering of expressions before they are output, using syntax similar to that available in HTML::Mason v1.Several filter functions come standard with Text::MicroMason. If HTML::Entities available, the "h" filter is set up to do HTML encoding. If URI::Escape is available, the "u" filter is set up to provide URI escaping. If those modules can not be loaded, no error message is produced but the corresponding filter will be unavailable. The "p" filter is set up to escape non-ascii characters using Perl backslash notation to make them printable. This filter is retained for backwards compatibility, but it is not recommended because it may destroy Unicode or other non-ascii byte streams. Use "filter_functions()" to define custom filter functions and associate them with filter names. Attempting to use an unknown filter name will croak with a message stating "No definition for a filter named 'h'". When specifying "default_filters()" or using filters in a MicroMason interpolation, there are two ways to specify multiple filters. You can only use one of these techinques in a filter specification, but default filters and inline filters can be specified differently. Up to 5 single character filters can be combined without delimiters: <% $name |hu %> Apply the "h" and "u" filters in that order. Any number of filter names of any length can be combined with commas and/or spaces: <% $name |u,js uc , h %> Apply the "u", "js", "uc", and "h" filters in that order. If the "n" filter is specified, all previously specified filters (including default filters) are skipped. <% $name |u,h,uc,n,js %> Apply the "js" filter only. <% $name |nu %> Skip default filters and apply the "u" filter. Public Methods
Supported Attributes
Private Methods
SEE ALSOFor an overview of this templating framework, see Text::MicroMason.This is a mixin class intended for use with Text::MicroMason::HTMLMason. For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe.
Visit the GSP FreeBSD Man Page Interface. |