Fern
view release on metacpan or search on metacpan
use strict;
use warnings;
use Test::Most;
use Test::Deep;
use Fern qw(tag empty_element_tag render_tag);
for my $tag_name (qw(
br
hr
input
))
{
is_deeply([empty_element_tag($tag_name)->()], ['<' . $tag_name . ' />'], $tag_name);
}
for my $tag_name (qw(
a
abbr
acronym
address
area
b
base
bdo
big
blockquote
body
button
caption
cite
code
col
colgroup
dd
del
div
dfn
dl
dt
em
fieldset
form
h1
h2
h3
h4
h5
h6
head
html
i
img
ins
kbd
label
legend
li
link
map
meta
noscript
object
ol
optgroup
option
p
param
pre
q
samp
script
select
small
span
strong
style
sub
sup
table
tbody
td
textarea
tfoot
th
thead
title
tr
tt
ul
var
))
{
is(render_tag(tag($tag_name)), '<' . $tag_name . '></' . $tag_name . '>', $tag_name);
}
is(render_tag(tag('div', {random => 'lala'})), '<div random="lala"></div>', 'Attributes');
is(render_tag(tag('div', {class => 'foo'}, tag('div', {class => 'bar'}, tag('div')))), '<div class="foo"><div class="bar"><div></div></div></div>', 'Containment');
is(render_tag(tag('div', [class => 'foo', name => 'foofoo'], 'Test')), '<div class="foo" name="foofoo">Test</div>', 'Ordered attributes');
my $got = render_tag(
tag('div', {class => 'modal hide fade imp-error-modal'},
tag('div', {class => 'modal-header'},
tag('button', {type => 'button', class => 'close', 'data-dismiss' => 'modal'}, 'Ã'),
tag('h3', 'A JavaScript error has occurred')),
tag('div', {class => 'modal-body'},
tag('p', "Please click the "Open RT" button to open an RT window and submit the error.",
"Add to the ticket how we can reproduce this error."),
tag('h4', 'Error Info'),
tag('pre', 'info')),
tag('div', {class => 'modal-footer'},
tag('a', {href => '#', class => 'btn', 'data-dismiss' => 'modal'},
'Ignore'),
tag('a', {href => '#', class => 'btn btn-primary'},
'Open RT')))
);
( run in 1.957 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )