NAME
HTML::Native::Literal - literal text to be included within HTML
SYNOPSIS
my
$literal
= HTML::Native::Literal->new (
"<p>Hello</p>"
);
$literal
;
# prints "<p>Hello</p>"
DESCRIPTION
An HTML::Native::Literal object represents a piece of text to be included within an HTML::Native tree without being subject to entity encoding.
You can use an HTML::Native::Literal object when you have some pre-existing HTML code that you want to include verbatim within an HTML::Native tree.
METHODS
new()
$literal
= HTML::Native::Literal->new ( <text> );
$literal
= HTML::Native::Literal->new ( \<text> );
Create a new HTML::Native::Literal object, representing some literal text to be included within an HTML document. For example:
my
$literal
= HTML::Native::Literal->new (
"<p>Hello</p>"
)
$literal
;
# prints "<p>Hello</p>"
or
my
$elem
= HTML::Native->new (
div
=>
[
h1
=>
"Welcome"
],
HTML::Native::Literal->new (
"<p>Hello</p>"
)
);
$elem
;
# prints "<div><h1>Welcome</h1><p>Hello</p></div>"
ADVANCED
MODIFIABLE LITERALS
If you pass a reference to a scalar variable, then the HTML::Native::Literal object will remain associated with the original variable. For example:
my
$text
=
"<p>Hello</p>"
;
my
$elem
= HTML::Native->new (
div
=>
[
h1
=>
"Welcome"
],
HTML::Native::Literal->new ( \
$text
),
);
$elem
;
# prints "<div><h1>Welcome</h1><p>Hello</p></div>"
$text
=
"<p>Goodbye</p>"
;
$elem
;
# now prints "<div><h1>Welcome</h1><p>Goodbye</p></div>"