HTML::...:Common(3pm)

πŸ“¦
version 0.40 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

HTML::Display::Common β€” routines common to all HTML::Display subclasses 🫢

Yep bestie, this is the HTML::...:Common(3pm) page, straight outta User Contributed Perl Documentation, and it's short because it's literally just the shared glue every subclass gets to inherit. Here's the whole vibe ✨


🌸 __PACKAGE__->new %ARGS 🌸

okay SO. This creates a brand-new object, and the object is just… a blessed hash πŸ’– The arguments you pass in get stored right there inside that hash. That's the entire constructor, no cap.

But listen β€” if your own subclass constructor needs to do other stuff, you still have to call this constructor too, or it all falls apart 😭 Like this:

package HTML::Display::WhizBang;
use parent 'HTML::Display::Common';

sub new {
  my ($class) = shift;
  my %args = @_;
  my $self = $class->SUPER::new(%args);

  # do stuff

  $self;
};

See how it hits that $class->SUPER::new(%args) before doing its own little thing? That's the move. And the example bottoms out on a lone $self;, just saying πŸ‘€

✨ $display->display %ARGS ✨

This is the routine that actually puts the HTML in front of your user's eyeballs πŸ‘‘ It takes these parameters:

  • html => SCALAR β€” a scalar holding the HTML 🌈
  • file => SCALAR β€” a scalar holding the filename of the file to be displayed πŸŽ€
  • base => β€” an optional base url for the HTML, so that relative links still work πŸ¦‹
  • location β€” synonymous to base πŸ’…

Basic usage, the moment you've all been waiting for:

my $html = "<html><body><h1>Hello world!</h1></body></html>";
my $browser = HTML::Display->new();
$browser->display( html => $html );

πŸ“ Location parameter πŸ“

Okay picture this: you fetched a page from a remote site but you still want to display it to the user. That is exactly the situation where the location parameter comes in very handy 🫢

my $html = '<html><body><img src="/images/hp0.gif"></body></html>';
my $browser = HTML::Display->new();

# This will display part of the Google logo
$browser->display( html => $html, base => 'http://www.google.com' );

And yes, the example uses base => right after telling you location is synonymous β€” it's giving "same thing, two names", and honestly? We love that for it πŸ’…


πŸ’œ AUTHOR πŸ’œ

Copyright (c) 2004-2013 Max Maischein "<corion@cpan.org>" β€” absolute icon, thank you for your service 🫑

🌈 LICENSE 🌈

This module is released under the same terms as Perl itself. Periodt. πŸ’…


and that's the whole page, bestie!! This was HTML::...:Common(3pm) from the User Contributed Perl Documentation, generated for perl v5.36.0 on 2022-10-15 ⭐ go forth and display some HTML, you got this πŸ’–πŸ¦‹

πŸ“¦ where this page comes from