NAME

HTML::String::Value - A scalar hiding as a string on behalf of HTML::String

SYNOPSIS

Usually, you'd create this with HTML::String's "html" in HTML::String export but:

my $html = HTML::String::Value->new($do_not_escape_this);

my $html = HTML::String::Value->new([ $do_not_escape_this, 0 ]);

my $html = HTML::String::Value->new([ $do_escape_this, 1 ]);

my $html = HTML::String::Value->new($already_an_html_string_value);

my $html = HTML::String::Value->new(@an_array_of_any_of_the_above);

my $html = HTML::String::Value->new(
  @parts, { ignore => { package_name => 1 } }
);

METHODS

new

my $html = HTML::String::Value->new(@parts, \%options?);

Each entry in @parts consists of one of:

'some text that will not be escaped'

[ 'some text that will not be escaped', 0 ]

[ 'text that you DO want to be escaped', 1 ]

$existing_html_string_value

Currently, the %options hashref contains only:

(
  ignore => { 'Package::One' => 1, 'Package::Two' => 1, ... }
)

which tells this value object to ignore whether escaping has been requested for any particular chunk and instead to provide the unescaped version.

When called on an existing object, does the equivalent of

$self->_hsv_unescaped_string->new(@args);

to fit in with the "pretending to be a class name" behaviour provided by "AUTOLOAD".

_hsv_escaped_string

$html->_hsv_escaped_string

Returns a concatenation of all parts of this value with those marked for escaping escaped, unless the calling package has been specified in the ignore option to "new".

If the calling package has been marked as ignoring escaping, returns the result of "_hsv_unescaped_string".

You probably shouldn't be calling this directly.

_hsv_unescaped_string

$html->_hsv_unescaped_string

Returns a concatenation of all parts of this value with no escaping performed.

You probably shouldn't be calling this directly.

_hsv_dot

$html->_hsv_dot($other_string, $reversed)

Returns a new value object consisting of the two values' parts concatenated together (in reverse if $reversed is true).

Unlike "new", this method defaults to escaping a bare string provided.

You probably shouldn't be calling this directly.

_hsv_is_true

$html->_hsv_is_true

Returns true if any of this value's parts are true.

You probably shouldn't be calling this directly.

AUTOLOAD

$html->method_name(@args)

This calls the equivalent of

$html->_hsv_unescaped_string->method_name(@args)

to allow for class method calls even when the class name has ended up being turned into a value object.

isa

$html->isa($name)

This method returns true if either the value or the unescaped string are isa the supplied $name in order to allow for class method calls even when the class name has ended up being turned into a value object.

can

$html->can($name)

This method returns a coderef if either the value or the unescaped string provides this method; methods on the unescaped string are preferred to allow for class method calls even when the class name has ended up being turned into a value object.

ref

$html->ref

This method always returns ''. Since we register ourselves with UNIVERSAL::ref, this means that

ref($html);

will also return '', which means that modules loaded after this one will see a value object as being a plain scalar unless they're explicitly checking the defined-ness of the return value of ref, which probably means that they wanted to spot people cheating like we're trying to.

If you have trouble with things trying to treat a value object as something other than a string, try loading UNIVERSAL::ref earlier.

DESTROY

Overridden to do nothing so that "AUTOLOAD" doesn't trap it.

OPERATOR OVERLOADS

stringification

Stringification is overloaded to call "_hsv_escaped_string"

concatenation

Concatentation is overloaded to call "_hsv_dot"

boolification

Boolification is overloaded to call "_hsv_is_true"

AUTHORS

See HTML::String for authors.

COPYRIGHT AND LICENSE

See HTML::String for the copyright and license.