HTML::...esolver(3pm)

πŸ’– HTML::Mason::Resolver(3pm) πŸ’–

okay bestie, welcome to the manual page for HTML::Mason::Resolver, from the User Contributed Perl Documentation section. it's giving base class energy, and honestly? we're obsessed. let's get into it 🫢


✨ NAME ✨

HTML::Mason::Resolver β€” the component path resolver base class, the blueprint, the moment πŸ’…


🌸 SYNOPSIS 🌸

# make a subclass and use it

that's literally it, that's the whole vibe. go forth and subclass ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: the resolver is responsible for translating a component path like /foo/index.html into a component. that's its whole job, that's its main character arc πŸŽ€

by default, Mason expects components to be stored on the filesystem, and it uses the HTML::Mason::Resolver::File class to get information on these components.

the HTML::Mason::Resolver provides a virtual parent class from which all resolver implementations should inherit. it's the mother of all resolvers, no cap πŸ‘‘

🌈 Class::Container 🌈

this class is used by most of the Mason object's to manage constructor parameters and has-a relationships with other objects.

see the documentation on this class for details on how to declare what parameters are valid for your subclass's constructor.

HTML::Mason::Resolver is a subclass of Class::Container so you do not need to subclass it yourself. one less thing, we love efficiency πŸ’…


πŸ’… METHODS πŸ’…

if you are interested in creating a resolver subclass, you must implement the following methods. no skipping, bestie, these are mandatory ✨

  • new β€” this method is optional. the new method included in this class is simply inherited from Class::Container. if you need something more complicated done in your new method you will need to override it in your subclass. otherwise just vibe and let the parent handle it 🫢
  • get_info β€” takes three arguments: an absolute component path, a component root key, and a component root path. returns a new HTML::Mason::ComponentSource object. three in, one out, immaculate ratio πŸ’–
  • glob_path β€” takes two arguments: a path glob pattern, something like "/foo/*" or "/foo/*/bar", and a component root path. returns a list of component paths for components which match this glob pattern.

for example, the filesystem resolver simply appends this pattern to the component root path and calls the Perl glob() function to find matching files on the filesystem. wildcards but make it file system πŸ¦‹

πŸ‘‘ Using a Resolver with HTML::Mason::ApacheHandler πŸ‘‘

if you are creating a new resolver that you intend to use with the HTML::Mason::ApacheHandler module, then you must implement the following method as well. extra credit, but like, required extra credit πŸ“

  • apache_request_to_comp_path ($r, @comp_root_array) β€” this method, given an Apache object and a list of component root pairs, should return a component path or undef if none exists. this method is used by the HTML::Mason::ApacheHandler class to translate web requests into component paths.

you can omit this method if your resolver subclass will never be used in conjunction with HTML::Mason::ApacheHandler. no Apache, no problem, skip it guilt-free πŸ™ˆ


⭐ reminder bestie: every resolver you build inherits from HTML::Mason::Resolver, and HTML::Mason::Resolver already inherits from Class::Container. don't double-subclass, it's not the vibe.

and that's the whole page, periodt πŸ’œ this was perl v5.38.2, dated 2024-03-05, straight out of the HTML::...esolver(3pm) page in the User Contributed Perl Documentation. go build something iconic with it, you absolute legend πŸŽ€βœ¨πŸŒˆ

πŸ“¦ where this page comes from