Text::...riables(3pm)

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

πŸ’– NAME πŸ’–

Text::MicroMason::PassVariables β€” it passes your template data in as variables ✨

(oh and btw the page header literally says Text::...riables(3pm) β€” truncated like that, no cap, it's giving mystery πŸ’€ but we know who she is)


✨ SYNOPSIS ✨

okay bestie, lowkey important: don't use this class directly, you pass its name in to get mixed in 🫢

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

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

print $mason->compile( text=>$template )->( 'name'=>'Dave' );
print $mason->execute( text=>$template, 'name'=>'Dave' );

and now your templates can access their arguments as global variables πŸ‘‘

Welcome, <% $name %>!

πŸ¦‹ DESCRIPTION πŸ¦‹

Like Text::Template, this package passes in template arguments as package variables. fr fr. so like, if you pass in an argument list of "foo => 23", it will set the variable $foo in the package your template is compiled in. which means your template code can just refer to $name instead of $ARGS{name} β€” so much cleaner, obsessed πŸ’…

The strict pragma is disabled to facilitate these variable references. yeah, she's living dangerously, that's the whole point 🌈

Caution: bestie please read this part πŸ™ˆ β€” this approach has some drawbacks, including the risk of clobbering global variables used for other purposes. It is included primarily to allow the TextTemplate module to emulate the behavior of Text::Template, and for quick-and-dirty simple templates where succinctness is more important than robustness. it's giving main character energy but also chaos, iykyk 😭

πŸŽ€ Supported Attributes πŸŽ€

  • package β€” target package namespace. defaults to Text::MicroMason::Commands πŸ’œ

🧚 Private Methods 🧚

  • assembler_rules() β€” adds Perl fragments to handle package and symbol table munging ✨
  • assemble() β€” modifies the Perl subroutine to embed the target package namespace πŸ”₯
  • install_args_hash() β€” performs symbol table munging to transfer the contents of an arguments hash into variables in a target namespace πŸ’«

🌸 SEE ALSO 🌸

the interface being emulated is described in Text::Template.

for an overview of this whole templating framework, see Text::MicroMason.

this is a mixin class intended for use with Text::MicroMason::Base.

for distribution, installation, support, copyright and license info, see Text::MicroMason::Docs::ReadMe ⭐


okay that's the whole page bestie, you ate πŸ’…βœ¨ this was Text::...riables(3pm) from the User Contributed Perl Documentation, built against perl v5.36.0 and dated 2023-08-10 β€” mwah, go slay some templates πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from