Text::...leQuote(3pm)

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

πŸ’… NAME πŸ’…

Text::MicroMason::DoubleQuote β€” a whole Minimalist Interpolation Engine, no cap ✨

(also hii this page lives in the User Contributed Perl Documentation section, so you know it's the real community-made stuff 🫢)


🌸 SYNOPSIS 🌸

okay so bestie, do not use this class all by itself. You pass its name in to get mixed in, like a little sprinkle on top:

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

and then your templates can be written using Perl's own double-quote interpolation syntax πŸŽ€

$coderef = $mason->compile( text => 'Hello $ARGS{name}!' );
print $coderef->( name => 'World' );

literally that's it, it's giving effortless πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

Text::MicroMason::DoubleQuote uses Perl's double-quoting interpolation as a minimalist syntax for templating. Iconic behaviour, honestly.

And like, of course you don't need this module for simple cases of interpolation β€” nobody's forcing you πŸ’€ β€” but if you're already using the MicroMason framework to process template files from disk, then this module should allow you to make your simplest templates run even faster. speed. slay.

✨ embedding the fancy stuff ✨

To embed values other than simple scalars in a double-quoted expression, you can use the ${ expr } syntax. For example, you can interpolate a function call with "${ \( time() ) }" or "@{[mysub(1,2,3)]}".

As noted in perldaq4, "this is fraught with quoting and readability problems, but it is possible." β€” and bestie, they were NOT lying 😭

⚠️ In particular, this can quickly become a mess once you start adding loops or conditionals. If you do find yourself making use of this feature, please consider switching to one of the more powerful template syntaxes like Text::MicroMason::HTMLMason. that's the glow-up, trust 🌈

πŸ‘‘ SEE ALSO πŸ‘‘

  • To refer to arguments as $name rather than as $ARGS{name}, see Text::MicroMason::PassVariables. cleaner, cuter, obsessed πŸ’œ
  • For an overview of this distribution, see Text::MicroMason. πŸ“š
  • This is a subclass 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 vibe check, bestie πŸŽ€ this page came from perl v5.36.0, dated 2023-08-10 β€” go forth and interpolate responsibly, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from