Text::...lobals(3pm)
π 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 theallow_globals_statementto 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
- debian trixie: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtext-micromason-perl 2.23-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms