NAME
HTML::EasyTemplate::PageMenu - make an HTML menus of your page.
DESCRIPTION
Provide an easy means of creating from a page's elements a representative block of HTML suitable for use as a substitution item in an HTML::Easytemplate, or as freestanding mark-up.
SYNOPSIS
Add links to TARGET
elements in HTML
; print the modified doc, followed by the modified MENU
:
use HTML::EasyTemplate::PageMenu;
my $m = new HTML::EasyTemplate::PageMenu (
'HTML' => 'test.html',
'TARGET' => ['H1','H2',],
);
print $m->{HTML},"\n";
print $m->{MENU},"\n";
Add the following lines to the above for a menu in an HTML::EasyTemplate, as TEMPLATEITEM name='menu1'
(based on the example provided in HTML::EasyTemplate
):
use HTML::EasyTemplate;
my $TEMPLATE = new HTML::EasyTemplate( $m->{HTML} );
$TEMPLATE -> process('fill', {'menu' => $m->{MENU}} );
$TEMPLATE -> save( 'E:/a/dir','new2.html');
print "Saved the document with a menu as <$TEMPLATE->{ARTICLE_PATH}>\n";
__END__
DEPENDENCIES
Cwd;
HTML::TokeParser;
URI::Escape;
strict;
warnings;
CONSTRUCTOR METHOD (new)
The method expects a package/class referemnce as it's first parameter. Following that, arguments should be passed in the form of an anonymous hash or as name/value pairs:
my $m = new HTML::EasyTemplate::PageMenu (
'arg1'=>'val1','arg2'=>'val2',
);
or:
my $m = new HTML::EasyTemplate::PageMenu (
{'arg1'=>'val1','arg2'=>'val2',}
);
ARGUMENTS
- HTML
-
As an argument: the page to process: either a scalar representing the path to a file, or a reference to a scalar that is the document to be parsed.
Then initiated as a public instance variable containing the modified HTML the object was called with (ie. with anchors inserted).
- TARGET
-
Array of case-insensitive scalars that represent the elements that contain text to be used in the menu (typically
[H1,H2]
). - LIST_START, LIST_END
-
HTML to wrap around the menu output.
Default is
UL
element. - ARTICLE_START, ARTICLE_END
-
HTML to wrap around each menu item.
Default is
LI
element.
METHOD create_fragment
Sets and returns $self-
{MENU}> - a fragment of HTML that is the menu of links which refers to the anchors embedded in the page by the constructor.
PRIVATE METHOD _anchorise
Parses the document looking for elements to use as menu items: adds an anchor before each, and stores them internally for future use in building the menu.
Returns undef on failure, reference to scalar of adjusted HTML on success.
TODO
Add a method to add to employ
HTML::EasyTemplate?
SEE ALSO
HTML::EasyTemplate HTML::EasyTemplate::DirMenu
AUTHOR
Lee Goddard (LGoddard@CPAN.org)
COPYRIGHT
Copyright 2000-2001 Lee Goddard.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 65:
'=item' outside of any '=over'
- Around line 128:
You forgot a '=back' before '=head2'
- Around line 214:
'=item' outside of any '=over'
Unterminated C<...> sequence
- Around line 218:
You forgot a '=back' before '=head1'