man-pages/man3/HTML::AsSubs.3pm.html
2021-03-31 01:06:50 +01:00

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">&nbsp;</A>
<H2>NAME</H2>
HTML::AsSubs - functions that construct a HTML syntax tree
<A NAME="lbAC">&nbsp;</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">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use HTML::AsSubs;
$h = body(
h1(&quot;This is the heading&quot;),
p(&quot;This is the first paragraph which contains a &quot;,
a({href=&gt;'link.html'}, &quot;link&quot;),
&quot; and an &quot;,
img({src=&gt;'img.gif', alt=&gt;'image'}),
&quot;.&quot;
),
);
print $h-&gt;as_HTML;
</PRE>
<A NAME="lbAE">&nbsp;</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>&quot;new_from_lol&quot;</TT> method.
<P>
For what I now think is a cleaner implementation of this same idea,
see the excellent module <TT>&quot;XML::Generator&quot;</TT>, which is what I suggest
for actual real-life use. (I suggest this over <TT>&quot;HTML::AsSubs&quot;</TT> and
over <TT>&quot;CGI.pm&quot;</TT>'s HTML-making functions.)
<A NAME="lbAF">&nbsp;</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=( '&quot;&quot;' =&gt; sub { join(&quot;&quot;, @{$_[0]}) } );
sub html { my($type)=shift; bless [&quot;&lt;$type&gt;&quot;, @_, &quot;&lt;/$type&gt;&quot;]; }
:-) 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">&nbsp;</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 &amp;tr(...) syntax
because it clashes with the builtin tr/../../ operator.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
HTML::Element, XML::Generator
<A NAME="lbAI">&nbsp;</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">&nbsp;</A>
<H2>Private Functions</H2>
<A NAME="lbAK">&nbsp;</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">&nbsp;</A>
<H2>AUTHOR</H2>
Current maintainers:
<DL COMPACT>
<DT id="1">&bull;<DD>
Christopher J. Madsen <TT>&quot;&lt;perl&nbsp;AT&nbsp;cjmweb.net&gt;&quot;</TT>
<DT id="2">&bull;<DD>
Jeff Fearn <TT>&quot;&lt;jfearn&nbsp;AT&nbsp;cpan.org&gt;&quot;</TT>
</DL>
<P>
Original HTML-Tree author:
<DL COMPACT>
<DT id="3">&bull;<DD>
Gisle Aas
</DL>
<P>
Former maintainers:
<DL COMPACT>
<DT id="4">&bull;<DD>
Sean M. Burke
<DT id="5">&bull;<DD>
Andy Lester
<DT id="6">&bull;<DD>
Pete Krawczyk <TT>&quot;&lt;petek&nbsp;AT&nbsp;cpan.org&gt;&quot;</TT>
</DL>
<P>
You can follow or contribute to HTML-Tree's development at
&lt;<A HREF="https://github.com/kentfredric/HTML-Tree">https://github.com/kentfredric/HTML-Tree</A>&gt;.
<A NAME="lbAM">&nbsp;</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">&nbsp;</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>