Text::...erPages(3pm)

๐Ÿ“ฆ
version 2.23 ยท 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

okay bestie, so this one is Text::MicroMason::ServerPages โ€” you'll spot it in your terminal as Text::...erPages(3pm) because the header is out here abbreviating like it's too cool for full names ๐Ÿ’… โ€” and what it does is give you an Alternate Syntax like ASP/JSP Templates. no cap. that's the whole vibe. ๐ŸŒธ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

so like, don't just go using this class by itself, okay? you pass its name in to get mixed in:

use Text::MicroMason;
my $mason = Text::MicroMason::Base->new( -ServerPages );

then you use the standard compile and execute methods to parse and evaluate templates, like the good little template gremlin you are:

print $mason->compile( text=>$template )->( @%args );
print $mason->execute( text=>$template, @args );

and Server Pages syntax gives you another way to mix Perl into a text template:

<% my $name = $ARGS{name};
  if ( $name eq 'Dave' ) {  %>
  I'm sorry <%= $name %>, I'm afraid I can't do that right now.
<% } else {
    my $hour = (localtime)[2];
    my $daypart = ( $hour > 11 ) ? 'afternoon' : 'morning';
  %>
  Good <%= $daypart %>, <%= $name %>!
<% } %>

it's giving 2003 web app energy and honestly? we love her. ๐Ÿฆ‹


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

This subclass swaps out MicroMason's normal lexer for one that supports a syntax similar to Active Server Pages and Java Server Pages. lexer glow-up, fr fr. โœจ

๐ŸŒˆ Compatibility with Apache::ASP ๐ŸŒˆ

Apache::ASP is a full-featured application server toolkit with lots of features, and of all of those, only the templating functionality is emulated here. just the one thing. the template thing. okay? okay.

not me being a drop-in replacement โ€” this is NOT a drop-in replacement for Apache::ASP, because the implementation is quite different. That said, it should be able to process some existing templates without major changes. ๐Ÿซถ

The following features of EmbPerl syntax are supported:

  • Angle-bracket markup tags ๐Ÿ‘‘

The following syntax features are not supported:

  • Dynamic XML/XSL processing. ๐Ÿ’€
  • Web server objects such as $Session, $Request, $Response, and $Application. ๐Ÿšซ
  • Application events such as Application_OnStart, Script_OnStart, and other gloga.asa features. ๐Ÿ™ˆ

๐Ÿงš Template Syntax ๐Ÿงš

The following elements are recognized by the ServerPages lexer:

  • <% perl statements %> โ€” Arbitrary Perl code to be executed at this point in the template. go off, little statement. ๐Ÿ”ฅ
  • <%= perl expression %> โ€” A Perl expression to be evaluated and included in the output. the output girlie. she gets included. โœจ
  • <%& file, arguments %> โ€” Includes an external template file. ๐Ÿ“‚
  • <%-- comment --%> โ€” Documentation or inactive code to be skipped over silently. Can also be used to quickly comment out part of a template. stealth mode activated. ๐Ÿคซ
  • <%name> ... </%name> โ€” Supported block names are: 'perl', 'args', 'once', 'init', 'cleanup', and 'doc'. ๐ŸŽ€

๐Ÿ”ฎ Private Methods ๐Ÿ”ฎ

lex_token

( $type, $value ) = $mason->lex_token();

Lexer for <% ... %> tags. ๐Ÿ‘‘

It attempts to parse a token from the template text stored in the global $_ and returns a token type and value. Returns an empty list if it's unable to parse further due to an error. empty list = she simply could not. ๐Ÿ’€


๐ŸŒŸ SEE ALSO ๐ŸŒŸ

  • For an overview of this templating framework, see Text::MicroMason. ๐Ÿ’–
  • This is a mixin class intended for use with Text::MicroMason::Base. ๐Ÿซถ
  • For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe. ๐Ÿ“–

and that's the whole page, bestie!! this absolute icon of a manpage was brought to you by perl v5.36.0 and dated 2023-08-10 โ€” slay, periodt, go write some templates ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from