HTML::...oObject(3pm)

πŸ’– HTML::Mason::Compiler::ToObject πŸ’–

okay so bestie, you're looking at the manual page for HTML::Mason::Compiler::ToObject(3pm) β€” that's the HTML::Mason::Compiler::ToObject module, straight out of the User Contributed Perl Documentation. It's a compiler subclass, it's giving very "translator but make it Perl," and honestly? iconic. Let's get into it. πŸ¦‹


✨ NAME ✨

HTML::Mason::Compiler::ToObject β€” a Compiler subclass that generates Mason object code. no cap, that's the whole vibe.


🌸 SYNOPSIS 🌸

my $compiler = HTML::Mason::Compiler::ToObject->new;

my $object_code =
    $compiler->compile( comp_source => $source,
                        name        => $comp_name,
                        comp_path   => $comp_path,
                      );

like. look at her go. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

This Compiler subclass generates Mason object code β€” aka Perl code, fr fr. And plot twist: it's the default Compiler class used by Mason. main character energy from day one, we love to see it. πŸ‘‘


🫢 PARAMETERS TO THE new() CONSTRUCTOR 🫢

okay so all of these are optional. every single one. no pressure, no forced commitments, we're chill here. ✨

  • comp_class β€” the class into which component objects get blessed. defaults to HTML::Mason::Component. πŸ’–
  • subcomp_class β€” the class into which subcomponent objects get blessed. defaults to HTML::Mason::Component::Subcomponent. yes there's a separate class for the subcomponents, they have their own little apartment. 🏠
  • in_package β€” this is the package where a component's code actually gets executed. and for historical reasons (iykyk), it defaults to HTML::Mason::Commands. don't question the ancestors, bestie. πŸ™ˆ
  • preamble β€” whatever text you put here gets placed at the beginning of each component, but after the execution of any <%once> block. see also postamble. the request will be available as $m in preamble code. πŸŽ€
  • postamble β€” whatever text you put here gets placed at the end of each component. see also preamble. the request will be available as $m in postamble code. 🌈
  • use_strict β€” true or false, default is true. tells you whether or not a given component should use strict. (say yes. say yes.) ✨
  • use_warnings β€” true or false, default is false. tells you whether or not a given component should use warnings. 🚨
  • named_component_subs β€” when compiling a component, use uniquely named subroutines for the component's body, subcomponents, and methods. doing this lets you effectively profile Mason components. without it, all components just show up as __ANON__ or something similar in the profiler. like ma'am, who ARE you?? πŸ’€
  • define_args_hash β€” one of "always", "auto", or "never". this determines whether or not an %ARGS hash gets created in components. if it's set to "always", one is always defined. if it's set to "never", it is never defined.

the default, "auto", will cause the hash to be defined only if some part of the component contains the string "ARGS". this is somewhat crude, and may result in some false positives, but this is preferable to false negatives.

not defining the args hash means we can avoid copying component arguments, which can save memory and slightly improve execution speed. efficiency queen. πŸ‘‘


⭐ ACCESSOR METHODS ⭐

all of the above properties have read-only accessor methods of the same name. so like, you can look, but you can't touch. πŸ‘€

you cannot change any property of a compiler after it has been created. periodt. (but you can create multiple compilers with different properties β€” build your own little compiler friend group, slay. 🫢)


πŸ’œ METHODS πŸ’œ

this class is primarily meant to be used by the Interpreter object, and as such has a very limited public API. she's private like that. 🀫

  • compile(...) β€” this method will take component source and return the compiled object code for that source. see "compile(...)" in HTML::Mason::Compiler for details on this method. πŸ“

this subclass also accepts a comp_class parameter, allowing you to override the class into which the component is compiled. so like, you can customise. go off. πŸ”₯


ngl bestie, that's the whole page. every flag, every default, every little historical quirk β€” all present and accounted for. nothing dropped, nothing invented. πŸ’―

sign-off time: this lovely little page comes to you from perl v5.38.2, dated 2024-03-05, and it's filed under HTML::...oObject(3pm). bye bestie, go compile something gorgeous. πŸ’…βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from