Text::...lobals(3pm)

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

πŸ’– Text::...lobals(3pm) β€” bestie, it's giving User Contributed Perl Documentation ✨

okay so this is Text::MicroMason::AllowGlobals, and the whole manual page you're looking at is literally called Text::...lobals(3pm) (yes the title got its nails done and got truncated, we love her anyway πŸ’…).


🌸 NAME 🌸

Text::MicroMason::AllowGlobals β€” share package vars between templates 🫢


✨ SYNOPSIS ✨

So here's the tea: don't use this class directly, bestie. Instead you pass its name in to be mixed in:

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

Now let's share some package variables πŸ‘‘

$mason->set_globals( '$name' => 'Bob' );

Then you use the standard compile and execute methods to parse and evaluate templates, like the icon you are:

print $mason->compile( text=>$template )->();
print $mason->execute( text=>$template );

And then, inside a template, you can refer to those globals:

Welcome, <% $name %>!

no cap, it just works πŸ’–


🌈 DESCRIPTION 🌈

πŸ’œ Public Methods

  • set_globals() β€” takes a list of pairs: global variable names and their corresponding values. For each variable name it adds that name to the allowed list and sets it to the initial value. Two-for-one, we love efficiency ✨
  • allow_globals() β€” gets or sets the variable names that are allowed.
    • If you call it with arguments, it adds them to the list. πŸ“
    • It returns the variables to be allowed as a list, or as a space-separated string in scalar context. Context-dependent queen πŸ’…

πŸŽ€ Supported Attributes

  • allow_globals β€” optional. Can be an array or a space-separated string of global variable names to be allowed. lowkey flexible, highkey iconic.

πŸ¦‹ Private Methods

  • assemble() β€” adds the allow_globals_statement to each token stream before assembling it. Backstage crew, doing the real work fr fr 🫢
  • allow_globals_statement() β€” this method prepends the "use vars" statement that's needed for the template subroutines to compile. If this doesn't happen, nothing compiles, and we'd simply pass away 😭

⭐ SEE ALSO ⭐

  • For 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. πŸ“š

🫢 reminder bestie: everything above is exactly what the page says β€” no invented options, no made-up behaviour. Just vibes and facts, periodt. πŸ’…

mwah πŸ’‹ this page was served up by perl v5.36.0 on 2023-08-10, and yes it's still answering to Text::...lobals(3pm) β€” she's booked, she's busy, she's iconic 🌟

πŸ“¦ where this page comes from