Michael Brown > HTML-Native > HTML::Native::Literal

Download:
HTML-Native-1.1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

HTML::Native::Literal - literal text to be included within HTML

SYNOPSIS ^

    use HTML::Native::Literal;

    my $literal = HTML::Native::Literal->new ( "<p>Hello</p>" );
    print $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>" )
    print $literal;
    # prints "<p>Hello</p>"

or

    my $elem = HTML::Native->new (
      div =>
      [ h1 => "Welcome" ],
      HTML::Native::Literal->new ( "<p>Hello</p>" )
    );
    print $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 ),
    );
    print $elem;
    # prints "<div><h1>Welcome</h1><p>Hello</p></div>"
    $text = "<p>Goodbye</p>";
    print $elem;
    # now prints "<div><h1>Welcome</h1><p>Goodbye</p></div>"
syntax highlighting: