.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::HTML5::Builder 3pm" .TH HTML::HTML5::Builder 3pm 2024-03-05 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME HTML::HTML5::Builder \- erect some scaffolding for your documents .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use HTML::HTML5::Builder qw[:standard JQUERY]; \& \& open my $fh, \*(Aq<\*(Aq, \*(Aqinline\-script.js\*(Aq; \& \& print html( \& \-lang => \*(Aqen\*(Aq, \& head( \& title(\*(AqTest\*(Aq), \& Meta(\-charset => \*(Aqutf\-8\*(Aq), \& ), \& body( \& h1(\*(AqTest\*(Aq), \& p(\*(AqThis is a test.\*(Aq), \& JQUERY(\-version => \*(Aq1.6.4\*(Aq), \& script(\-type => \*(Aqtext/javascript\*(Aq, $fh), \& ), \& ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module can export function names corresponding to any HTML5 element. .PP Each function returns an XML::LibXML::Element with the same name as the function. The arguments to each function are processed as a list, and used to set the attributes and contents of that element. .PP For each item on the list: .IP \(bu 4 if it's an XML::LibXML::Element, XML::LibXML::TextNode, XML::LibXML::Comment, or XML::LibXML::PI, it's appended as a child of the returned element. .IP \(bu 4 if it's an XML::LibXML::NodeList, each item on the list is appended as a child of the returned element. .IP \(bu 4 if it's an XML::LibXML::Attr, it's set as an attribute on the returned element .IP \(bu 4 if it's an IO::Handle, then it will be slurped and appended to the returned element as a text node. .IP \(bu 4 if it's a scalar reference, then the returned element is also assigned to it. (This feature is \fBat risk\fR.) .IP \(bu 4 if it's a scalar (string) some guesswork is conducted to figure out whether you're setting an attribute and value, or whether the string should be used as a text node. The presence of a hyphen at the start of the string is the main deciding factor. .Sp .Vb 1 \& p(\*(Aq\-class\*(Aq, \*(Aqwarning\*(Aq, \*(Aq$LordLucan not found.\*(Aq); .Ve .Sp In this example, a paragraph element is returned, with the class attribute set to 'warning' and the textual contents '$LordLucan not found.'. .Sp Sometimes it's necessary to protect values against this guesswork. By passing a hashref, all the keys and values are interpreted as setting attributes; by passing an arrayref, all values are interpreted as setting the contents of the element. .Sp .Vb 1 \& p([\*(Aq\-class\*(Aq], { warning => \*(Aq$LordLucan not found.\*(Aq }); .Ve .Sp In this example, a paragraph element is returned, with the warning attribute set to '$LordLucan not found.' and the textual contents '\-class'. .IP \(bu 4 Anything else is stringified and added as a text node. This is useful for things with sensible stringification defined, such as \f(CW\*(C`DateTime\*(C'\fR and \f(CW\*(C`URI\*(C'\fR objects, but less so for some other objects, so you will sometimes get a warning if warnings are enabled. Warnings can be disabled using: .Sp .Vb 1 \& no warnings \*(AqHTML::HTML::Builder\*(Aq; .Ve .SS "Exceptional Cases" .IX Subsection "Exceptional Cases" The \f(CW\*(C`html\*(C'\fR function does not return an \f(CW\*(C`XML::LibXML::Element\*(C'\fR, but rather a \&\f(CW\*(C`HTML::HTML5::Builder::Document\*(C'\fR object. .PP There is special handling for \f(CW\*(C`time\*(C'\fR (or \f(CW\*(C`Time\*(C'\fR). If the first parameter passed to it is a DateTime object, then that object is used to set its datetime attribute. If there are no subsequent parameters, then the stringified form of the object is also used to form the content of the