Form::Sensible::Renderer - Base class for Renderers.


Form-Sensible documentation Contained in the Form-Sensible distribution.

Index


Code Index:

NAME

Top

Form::Sensible::Renderer - Base class for Renderers.

DESCRIPTION

Top

This module provides a base class for renderers. It's not very interesting.

METHODS

Top

render($form)

Returns a rendered representation of the form.

render_hints_for($renderer_name, $thing)

Returns the render hints for the given type. This looks for an element called renderer_name in $thing->render_hints. If found, it is returned, otherwise returns $thing->render_hints. This is used to allow for specification of different renderhints within the same form for use by different renderers.

AUTHOR

Top

Jay Kuri - <jayk@cpan.org>

SPONSORED BY

Top

SEE ALSO

Top

Form::Sensible

LICENSE

Top

Copyright 2009 by Jay Kuri <jayk@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Form-Sensible documentation Contained in the Form-Sensible distribution.

package Form::Sensible::Renderer;

use Moose; 
use namespace::autoclean;

## this module provides the basics for rendering of forms / fields
##
## should this be an abstract role that defines the interface for rendering?

sub render_hints_for {
    my ($self, $renderer_name, $thing) = @_;
    
    my $hints = $thing->render_hints();
    
    if (exists($hints->{$renderer_name})) {
        return $hints->{$renderer_name};
    } else {
        return $hints;
    }
}

sub render {
    my ($self, $form) = @_;
    
    die "Unable to render " . $form->name . " because you are trying to use an abstract base class to render.";
}


__PACKAGE__->meta->make_immutable;
1;

__END__