HTML::Shakan::Renderer::HTML - HTML::Shakan::Renderer::HTML documentation


HTML-Shakan documentation Contained in the HTML-Shakan distribution.

Index


Code Index:

DESCRIPTION

Top

simple HTML renderer for HTML::Shakan.


HTML-Shakan documentation Contained in the HTML-Shakan distribution.

package HTML::Shakan::Renderer::HTML;
use Any::Moose;
use HTML::Shakan::Utils;

has 'id_tmpl' => (
    is => 'ro',
    isa => 'Str',
    default => 'id_%s',
);

sub render {
    my ($self, $form) = @_;

    my @res;
    for my $field ($form->fields) {
        unless ($field->id) {
            $field->id(sprintf($self->id_tmpl(), $field->{name}));
        }
        if ($field->label) {
            push @res, sprintf( q{<label for="%s">%s</label>},
                $field->{id}, encode_entities( $field->{label} ) );
        }
        push @res, $form->widgets->render( $form, $field );
    }
    join '', @res;
}

no Any::Moose;
__PACKAGE__->meta->make_immutable;
__END__