Text::...emplate(3pm)

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

πŸ’– NAME πŸ’–

Text::MicroMason::QuickTemplate β€” alternate syntax, lowkey iconic, literally just like Text::QuickTemplate. πŸ¦‹

This is a page from the perl manual, bestie β€” Text::...emplate(3pm), if you're keeping track. πŸ‘‘


✨ SYNOPSIS ✨

okay so first thing: do not use this class directly, no cap. You pass its name in so it gets mixed in:

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

Then you use the standard compile and execute methods to parse and evaluate your templates, slay:

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

Or, if you'd rather roll with Text::QuickTemplate's calling conventions (main character energy tbh):

$template = Text::MicroMason->new( -HTMLTemplate, text=>'simple.tmpl' );
print $template->fill( %arguments );

Text::QuickTemplate hands you a syntax to embed values into a text template, and it's giving:

Good {{timeofday}}, {{name}}!

🌸 DESCRIPTION 🌸

So this is a mixin class, and what it does is override several methods so that MicroMason can emulate the template syntax of Text::QuickTemplate plus some of its other features too. πŸ’…

And not me casually dropping that it automatically includes these other mixins, for free, no extra charge:

  • TemplateDir
  • HasParams
  • StoreOne

πŸŽ€ Compatibility with Text::QuickTemplate πŸŽ€

okay real talk: this is not a drop-in replacement for Text::QuickTemplate, because the implementation is quite different. 😭 But it should be able to process most existing templates without major changes, so like… we move. 🫢

The following features of EmbPerl syntax are supported:

  • Curly bracketed tags with parameter names. πŸŽ€
  • Array of parameters hashes.
  • Special $DONTSET variable. (iconic, mysterious, we respect her)

🌈 SEE ALSO 🌈

  • The interface being emulated is described in Text::QuickTemplate.
  • 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, go forth and template responsibly πŸ’œ

this was perl v5.36.0, dated 2023-08-10 β€” so like, vintage but still ate. πŸ’…βœ¨

πŸ“¦ where this page comes from