Text::...on::PLP(3pm)

πŸ“¦
version 2.23 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Text::...on::PLP β€” the manual page, but make it cute πŸ’–

okay bestie, so this is Text::...on::PLP, living in the User Contributed Perl Documentation, and it's literally the PLP-syntax glow-up for MicroMason. Let's get into it πŸ¦‹


✨ NAME ✨

Text::MicroMason::PLP β€” Alternate Syntax like PLP Templates. yeah that's the whole name, she's lowkey mysterious like that πŸ’…


🌸 SYNOPSIS 🌸

bestie do NOT instantiate this class directly, okay? instead you pass its name in so it gets mixed in, like:

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

then you use the standard compile and execute methods to parse and evaluate your templates:

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

the PLP syntax is just another way to mix Perl into a text template, and it's giving:

<: 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 :>!
<: } :>

πŸ‘‘ DESCRIPTION πŸ‘‘

so this subclass replaces MicroMason's normal lexer with one that supports a syntax similar to the one the PLP module provides. iconic behavior honestly.

πŸŽ€ Compatibility with PLP πŸŽ€

PLP is a web-oriented system with many fatures, and of all of those, only the templating functionality is emulated. just the one. that's the vibe.

this is not a drop-in replacement for PLP, because the implementation is quite different β€” but it should be able to process some existing templates without major changes. no cap 🫢

the following features of EmbPerl syntax are supported:

  • Basic markup tags

the following syntax features of are not supported:

  • Emulation of functions defined in PLP::Functions is incomplete.
  • Web server interface with tied
🚨 bestie heads up: those two are the NOT-supported list, so don't come for me when they don't work, they were never invited πŸ’€

πŸ¦‹ Template Syntax πŸ¦‹

the following elements are recognized by the PLP lexer:

  • <: perl statements :> β€” Arbitrary Perl code to be executed at this point in the template. just vibing, running code, living its truth.
  • <:= perl expression :> β€” A Perl expression to be evaluated and included in the output. this one shows up in the text. main character energy, honestly.
  • <( file, arguments )> β€” Includes an external template file. bringing a friend along 🫢

🧚 Private Methods 🧚

these are the backstage girlies. private. iykyk.

lex_token

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

Lexer for <: ... :> and <( ... )> 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. so like, if it ghosts you, that's why 😭

assemble

Performs compile-time file includes for any include tokens found by lex_token. teamwork, makes the dream work ✨


πŸ’œ SEE ALSO πŸ’œ

  • the interface being emulated is described in PLP.
  • 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 lil doc came from perl v5.36.0 and it's dated 2023-08-10 β€” so if you're reading it from the future, hi, hope you slayed πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from