Text::...Numbers(3pm)

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

πŸ’– Text::MicroMason::LineNumbers πŸ’–

okay bestie, this is the User Contributed Perl Documentation page for Text::MicroMason::LineNumbers (that's the 3pm one, you know the vibe ✨).


✨ NAME ✨

Text::MicroMason::LineNumbers β€” no cap, its whole job is reporting errors at the correct source code line numbers. 🎯


🌸 DESCRIPTION 🌸

So this is a mixin class (iykyk) and what it does is associate every single token in a template with the line number where it was found. Then it inserts special comments into the generated Perl code that preserve that original source file + line number info. πŸ¦‹

It's giving debugging glow-up, fr fr β€” it makes it so much easier to match up runtime errors with the actual template code that produced them. πŸ˜­πŸ’…

To turn this behavior on, just add -LineNumbers to your MicroMason creation call:

my $mason = Text::MicroMason->new( qw( -LineNumbers ) );

πŸ‘‘ Public Methods πŸ‘‘

These methods get called from within the normal flow of MicroMason functionality, so you do not need to invoke them directly. They're just doing their thing backstage. πŸ’œ

  • read() β€” Clears the variables used to store the file name and first line of a template, so that they can be set by the methods below. Wiping the slate clean, periodt. 🧚
  • read_file() β€” Saves the source file name before invoking the standard behavior for this method.
$mason->compile( file => $filename );
  • read_handle() β€” Saves the caller's file name before invoking the standard behavior for this method.
$mason->compile( handle => $filename );
  • read_text() β€” Saves the caller's file name before invoking the standard behavior for this method.
$mason->compile( text => $filename );
  • read_inline() β€” This one's similar to read_text, except it adjusts the line numbering to reflect a template that's embedded as a literal text in the Perl code. Sneaky but iconic. πŸ™ˆ
$mason->compile( inline => q{
        My template text goes here.
} );
  • lex() β€” Identical to the lex() method provided by the Base class, except that it also inserts a stream of line-number-setting comments into the to-be-compiled Perl code that attempt to re-synchronize the
  • assembler_rules() β€” Maps the line_num token to a perl line number comment. πŸ’«

πŸŽ€ Private Methods πŸŽ€

  • _get_external_caller() β€” Returns the source file and line number of the first item in the function call stack that is not a Text::MicroMason package. Lowkey the detective of the whole operation. πŸ”

🌈 SEE ALSO 🌈

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

heads up bestie, the lex() description above really does trail off mid-sentence like that. I'm not fixing it, I'm not guessing the rest β€” I'm just reporting what's on the page. πŸ’€

and that's the whole thing!! this page is from perl v5.36.0, dated 2023-08-10, and it's part of the Text::...Numbers(3pm) manual. mwah, slay, go forth and debug with accurate line numbers βœ¨πŸ’–

πŸ“¦ where this page comes from