Description | A static content generator. |
Newcomen::Renderer - Renderer frontend.
use Newcomen::Renderer; my $renderer = Newcomen::Renderer -> new (); $render -> render_page ($page);
Newcomen::Renderer is the frontend for the page rendering modules. The actual rendering will be done by backends. The rendering backend to use and its options are set on a per-page basis (see Newcomen::Page).
Plugins may use Newcomen::Role::Attribute::Renderer to access the main renderer instance, but usually this should not be necessary.
my $renderer = Newcomen::Renderer -> new ();
Constructor. Expects no parameters.
Toggle source: render_page
sub render_page { my $self = shift; my $page = shift; return unless defined $page -> renderer (); my $name = $page -> renderer () -> name (); my $full = "Newcomen::Renderer::$name"; confess "No such renderer: $name" unless $self -> backend ($full); $page -> rendered ( $self -> backend ($full) -> render ($page, $page -> renderer () -> options ()) ); }
$renderer -> render_page ($page);
Expects a single Newcomen::Page instance as parameter. If there is a renderer backend set for the
page, the backend will be called to render it. The rendered content will automatically be set for
the page (see Newcomen::Page's rendered() method). The return value of
this method is not specified. Details and backend options may differ for different backends, see the
appropriate documentation for details. Backend names must be module basenames only (i.e. without the
'Newcomen::Renderer::'
prefix), and names are case sensitive. The backend must exist, else this
method will die().
The methods backend(), backend_exists() and backends() are available to access the renderer backends, though usually this should not be necessary. For a description of these methods please see Newcomen::Role::Frontend.
Backends must use Newcomen::Renderer::Backend as their base class. They must be placed in the Newcomen::Renderer namespace, and implement a _do_render() method. For more details, see Newcomen::Renderer::Backend.
Newcomen::Page, Newcomen::Renderer::Backend, Newcomen::Role::Attribute::Renderer, Newcomen::Role::Frontend
This is version 2014052501
.
Stefan Goebel - newcomen {at} subtype {dot} de
Copyright 2013-2014 Stefan Goebel.
This file is part of Newcomen.
Newcomen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.
Newcomen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Newcomen. If not, see <http://www.gnu.org/licenses/>.