GX::Renderer - Renderer class
# Load the module use GX::Renderer; # Create a new renderer my $renderer = GX::Renderer->new; # Set the renderer's "xml"-format handler $renderer->handler( xml => GX::Callback::Method->new( invocant => $application->view( 'XML' ), method => 'render' ) ); # Render $renderer->render( xml => ( context => $context, tidy => 1 ) );
This module provides the GX::Renderer class which extends the GX::Class::Object class.
new
Returns a new GX::Renderer object.
$renderer = GX::Renderer->new( %attributes );
handlers ( HASH reference )
handlers
HASH
A reference to a hash with format / handler pairs. Handlers must be GX::Callback objects.
$renderer ( GX::Renderer object )
$renderer
GX::Exception
can_render
Returns true if the renderer can handle the specified format, otherwise false.
$result = $renderer->can_render( $format );
$format ( string )
$format
$result ( bool )
$result
clone
Clones the renderer.
$clone = $renderer->clone;
$clone ( GX::Renderer object )
$clone
formats
Returns a list with the formats supported by the renderer.
@formats = $renderer->formats;
@formats ( strings )
@formats
handler
Returns / sets the handler for the specified format.
$handler = $renderer->handler( $format ); $handler = $renderer->handler( $format, $handler );
$handler ( GX::Callback object | undef ) [ optional ]
$handler
undef
$handler ( GX::Callback object | undef )
Returns all format handlers.
@handlers = $renderer->handlers;
@handlers ( GX::Callback objects )
@handlers
merge
Adds the format handlers from the given renderers.
$renderer->merge( @renderers );
@renderers ( GX::Renderer objects )
@renderers
Already existing handlers are replaced.
render
Executes the specified format handler.
$renderer->render( $format, @arguments );
@arguments ( scalars )
@arguments
Exceptions raised in the handler are caught and rethrown. If render() is called in void context, an exception is raised if the specified format is not supported by the renderer. In non-void context, render() returns false if the specified format is not supported, otherwise true.
render()
$result = $renderer->render( $format, @arguments );
If set, the "*" format handler acts as a fallback.
Jörg A. Uzarek <uzarek@runlevelnull.de>
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.