NAME HTML::HTML5::Builder - erect some scaffolding for your documents SYNOPSIS use HTML::HTML5::Builder qw[:standard JQUERY]; open my $fh, '<', 'inline-script.js'; print html( -lang => 'en', head( title('Test'), Meta(-charset => 'utf-8'), ), body( h1('Test'), p('This is a test.'), JQUERY(-version => '1.6.4'), script(-type => 'text/javascript', $fh), ), ); DESCRIPTION This module can export function names corresponding to any HTML5 element. 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. For each item on the list: * 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. * if it's an XML::LibXML::NodeList, each item on the list is appended as a child of the returned element. * if it's an XML::LibXML::Attr, it's set as an attribute on the returned element * if it's an IO::Handle, then it will be slurped and appended to the returned element as a text node. * if it's a scalar reference, then the returned element is also assigned to it. (This feature is at risk.) * 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. p('-class', 'warning', '$LordLucan not found.'); In this example, a paragraph element is returned, with the class attribute set to 'warning' and the textual contents '$LordLucan not found.'. 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. p(['-class'], { warning => '$LordLucan not found.' }); In this example, a paragraph element is returned, with the warning attribute set to '$LordLucan not found.' and the textual contents '-class'. * Anything else is stringified and added as a text node. This is useful for things with sensible stringification defined, such as "DateTime" and "URI" objects, but less so for some other objects, so you will sometimes get a warning if warnings are enabled. Warnings can be disabled using: no warnings 'HTML::HTML::Builder'; Exceptional Cases The "html" function does not return an "XML::LibXML::Element", but rather a "HTML::HTML5::Builder::Document" object. There is special handling for "time" (or "Time"). 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