has
'html'
=> (
is
=>
'rw'
,
isa
=>
'Str'
,
builder
=>
'build_html'
);
sub
build_html {
''
}
has
'set_html'
=> (
isa
=>
'Str'
,
is
=>
'ro'
);
sub
_set_html_meth {
my
$self
=
shift
;
return
$self
->set_html
if
$self
->set_html;
my
$name
=
$self
->full_name;
$name
=~ s/\./_/g;
$name
=~ s/_\d+_/_/g;
return
'html_'
.
$name
;
}
sub
_can_form_html {
my
$self
=
shift
;
my
$set_html
=
$self
->_set_html_meth;
return
unless
$self
->form &&
$set_html
&&
$self
->form->can(
$set_html
);
return
$set_html
;
}
sub
_form_html {
my
$self
=
shift
;
return
unless
(
my
$meth
=
$self
->_can_form_html);
if
(
$self
->form->meta->has_attribute(
$meth
) ) {
return
$self
->form->
$meth
;
}
else
{
return
$self
->form->
$meth
(
$self
);
}
}
sub
render {
my
$self
=
shift
;
if
(
my
$meth
=
$self
->_can_form_html ) {
return
$self
->form->
$meth
(
$self
);
}
elsif
(
$self
->html ) {
return
$self
->html;
}
return
''
;
}
__PACKAGE__->meta->make_immutable;
1;