Andrew Sterling Hanenkamp > Contentment-0.011_033 > Contentment::Generator::HTML

Download:
Contentment-0.011_033.tar.gz

Dependencies

Annotate this POD

Module Version: 0.07   Source  

NAME ^

Contentment::Generator::HTML - Generator for HTML text

SYNOPSIS ^

  my $generator = Contentment::Generator::HTML->new({
      source => <<'END_OF_HTML',
  <html>
  <head>
  <title>This is an example.</title>
  <meta name="foo" content="1"/>
  <meta name="bar" content="2"/>
  </head>
  <body>
  <h1>This is an example.</h1>

  <p>Exampling we will go! Exampling we will go!<br/>
  Hi-Ho-A-Merry-Oh! Exampling we will go!</p>
  </body>
  </html>
  END_OF_HTML

DESCRIPTION ^

This is a generator for HTML files. It basically understands the title and meta tags. It strips the body out of the HTML and passes it on. This way, each HTML file is a complete file in and of itself, but we can wrap it in nice themes without too much effort.

$generator = Contentment::Generator::HTML->new(\%args)

Constructs an HTML generator. It accepts the following arguments:

source (required)

This is the HTML text to generate. It takes the same forms as Contentment::Generator::Plain's constructor.

properties (optional, defaults to {})

The get_property() method searches for meta-tags in the HTML source and uses those as properties. If you wish to have additional properties that aren't defined in the meta tags, you may add them with this option. These options create additional properties, they do not override the meta tags in the file.

$properties = $generator->properties

This decodes the properties found defined by meta-tags in the source as well as returning any properties set in the constructor. The meta-tags in the file will override any properties given to the constructor.

$source = $generator->source

Parses the HTML and it's properties in addition to reading the source.

$result = $generator->get_property($key)

Returns the contents of the title tag when $key is "title".

Returns the contents of the content attribute of any meta tag where the key matches the given $key.

$result = $generator->generate

Prints the body of the HTML file.

HOOK HANDLERS

Contentment::Generator::HTML::match

Handles the "Contentment::FileType::match" hook.

SEE ALSO ^

Contentment::FileType::Other

AUTHOR ^

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE ^

Contentment is distributed and licensed under the same terms as Perl itself.

syntax highlighting: