216 lines
6.0 KiB
HTML
216 lines
6.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of HTML::AsSubs</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>HTML::AsSubs</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-01-13<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
HTML::AsSubs - functions that construct a HTML syntax tree
|
|
<A NAME="lbAC"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
|
|
|
|
This document describes version 5.07 of
|
|
HTML::AsSubs, released August 31, 2017
|
|
as part of HTML-Tree.
|
|
<A NAME="lbAD"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use HTML::AsSubs;
|
|
$h = body(
|
|
h1("This is the heading"),
|
|
p("This is the first paragraph which contains a ",
|
|
a({href=>'link.html'}, "link"),
|
|
" and an ",
|
|
img({src=>'img.gif', alt=>'image'}),
|
|
"."
|
|
),
|
|
);
|
|
print $h->as_HTML;
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module exports functions that can be used to construct various
|
|
<FONT SIZE="-1">HTML</FONT> elements. The functions are named after the tags of the
|
|
corresponding <FONT SIZE="-1">HTML</FONT> element and are all written in lower case. If the
|
|
first argument is a hash reference then it will be used to initialize the
|
|
attributes of this element. The remaining arguments are regarded as
|
|
content.
|
|
<P>
|
|
|
|
For a similar idea (i.e., it's another case where the syntax tree
|
|
of the Perl source mirrors the syntax tree of the <FONT SIZE="-1">HTML</FONT> produced),
|
|
see HTML::Element's <TT>"new_from_lol"</TT> method.
|
|
<P>
|
|
|
|
For what I now think is a cleaner implementation of this same idea,
|
|
see the excellent module <TT>"XML::Generator"</TT>, which is what I suggest
|
|
for actual real-life use. (I suggest this over <TT>"HTML::AsSubs"</TT> and
|
|
over <TT>"CGI.pm"</TT>'s HTML-making functions.)
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ACKNOWLEDGEMENT</H2>
|
|
|
|
|
|
|
|
This module was inspired by the following message:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
Date: Tue, 4 Oct 1994 16:11:30 +0100
|
|
Subject: Wow! I have a large lightbulb above my head!
|
|
|
|
Take a moment to consider these lines:
|
|
|
|
%OVERLOAD=( '""' => sub { join("", @{$_[0]}) } );
|
|
|
|
sub html { my($type)=shift; bless ["<$type>", @_, "</$type>"]; }
|
|
|
|
:-) I *love* Perl 5! Thankyou Larry and Ilya.
|
|
|
|
Regards,
|
|
Tim Bunce.
|
|
|
|
p.s. If you didn't get it, think about recursive data types: html(html())
|
|
p.p.s. I'll turn this into a much more practical example in a day or two.
|
|
p.p.p.s. It's a pity that overloads are not inherited. Is this a bug?
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
|
|
|
|
The exported <B>link()</B> function overrides the builtin <B>link()</B> function.
|
|
The exported <B>tr()</B> function must be called using &tr(...) syntax
|
|
because it clashes with the builtin tr/../../ operator.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
HTML::Element, XML::Generator
|
|
<A NAME="lbAI"> </A>
|
|
<H3>html head title base link meta isindex nextid script style body h1 h2 h3 h4 h5 h6 p pre div blockquote a img br hr ol ul dir menu li dl dt dd dfn cite code em kbd samp strong var address span b i u tt center font big small strike sub sup table tr td th caption form input select option textarea object applet param map area frame frameset noframe</H3>
|
|
|
|
|
|
|
|
A bunch of methods for creating tags.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>Private Functions</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3><B>_elem()</B></H3>
|
|
|
|
|
|
|
|
The <B>_elem()</B> function is wrapped by all the html 'tag' functions. It
|
|
takes a tag-name, optional hashref of attributes and a list of content
|
|
as parameters.
|
|
<A NAME="lbAL"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Current maintainers:
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
Christopher J. Madsen <TT>"<perl AT cjmweb.net>"</TT>
|
|
<DT id="2">•<DD>
|
|
Jeff Fearn <TT>"<jfearn AT cpan.org>"</TT>
|
|
</DL>
|
|
<P>
|
|
|
|
Original HTML-Tree author:
|
|
<DL COMPACT>
|
|
<DT id="3">•<DD>
|
|
Gisle Aas
|
|
</DL>
|
|
<P>
|
|
|
|
Former maintainers:
|
|
<DL COMPACT>
|
|
<DT id="4">•<DD>
|
|
Sean M. Burke
|
|
<DT id="5">•<DD>
|
|
Andy Lester
|
|
<DT id="6">•<DD>
|
|
Pete Krawczyk <TT>"<petek AT cpan.org>"</TT>
|
|
</DL>
|
|
<P>
|
|
|
|
You can follow or contribute to HTML-Tree's development at
|
|
<<A HREF="https://github.com/kentfredric/HTML-Tree">https://github.com/kentfredric/HTML-Tree</A>>.
|
|
<A NAME="lbAM"> </A>
|
|
<H2>COPYRIGHT AND LICENSE</H2>
|
|
|
|
|
|
|
|
Copyright 1995-1998 Gisle Aas, 1999-2004 Sean M. Burke,
|
|
2005 Andy Lester, 2006 Pete Krawczyk, 2010 Jeff Fearn,
|
|
2012 Christopher J. Madsen.
|
|
<P>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the same terms as Perl itself.
|
|
<P>
|
|
|
|
The programs in this library are distributed in the hope that they
|
|
will be useful, but without any warranty; without even the implied
|
|
warranty of merchantability or fitness for a particular purpose.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="8"><A HREF="#lbAC">VERSION</A><DD>
|
|
<DT id="9"><A HREF="#lbAD">SYNOPSIS</A><DD>
|
|
<DT id="10"><A HREF="#lbAE">DESCRIPTION</A><DD>
|
|
<DT id="11"><A HREF="#lbAF">ACKNOWLEDGEMENT</A><DD>
|
|
<DT id="12"><A HREF="#lbAG">BUGS</A><DD>
|
|
<DT id="13"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
<DL>
|
|
<DT id="14"><A HREF="#lbAI">html head title base link meta isindex nextid script style body h1 h2 h3 h4 h5 h6 p pre div blockquote a img br hr ol ul dir menu li dl dt dd dfn cite code em kbd samp strong var address span b i u tt center font big small strike sub sup table tr td th caption form input select option textarea object applet param map area frame frameset noframe</A><DD>
|
|
</DL>
|
|
<DT id="15"><A HREF="#lbAJ">Private Functions</A><DD>
|
|
<DL>
|
|
<DT id="16"><A HREF="#lbAK"><B>_elem()</B></A><DD>
|
|
</DL>
|
|
<DT id="17"><A HREF="#lbAL">AUTHOR</A><DD>
|
|
<DT id="18"><A HREF="#lbAM">COPYRIGHT AND LICENSE</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:45 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|