#!/usr/bin/perl
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
=
'hello>'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
'hello>'
,
'> => >'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
=
'hello >'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
'hello &gt;'
,
'& => &'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
=
'hello'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
'hello'
,
'hello'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
=
'hello<br />'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
'hello<br />'
,
'do not escape <br />'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
= '
 
;
hello<br />';
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
" \n hello<br />"
,
'do not escape either'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$text
=
' hello<br />'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
$text
);
my
$output
=
$tmpl
->output;
is
$output
,
' hello<br />'
,
'test'
;
}
{
my
$template
=
'<%= test ESCAPE=HTML_WITHOUT_NBSP %>'
;
my
$tmpl
= HTML::Template::Compiled->new(
scalarref
=> \
$template
,
plugin
=> [
'HTML::Template::Compiled::Plugin::HTML2'
],
);
$tmpl
->param(
test
=>
undef
);
my
$output
=
$tmpl
->output;
is
$output
,
''
,
'test - undef'
;
}
done_testing;