NAME
Punk::Views - the pluggable view engine registry (XS)
DESCRIPTION
Each views $name => \%opts call in the DSL registers one engine. $name resolves to Punk::View::$name; '+Full::Class' uses the class as written. The engine contract is two methods and nothing more - adding view backends never touches the dispatch path:
my $engine = Engine->new(\%opts);
my $bytes = $engine->render($template_name, \%data);
The first registered engine is the default; $c->render($tpl, \%data, engine => 'Other') selects per render, type => '...' overrides the content type, status => ... the status. Everything resolves and croaks at to_app, never per request.
Implemented entirely in C (include/punk/punk_views.h): the object is a blessed IV-ref to the engine registry, and render - the hot path - looks the engine up, calls its render, and assembles the PSGI triplet in C, so a rendered page crosses the Perl boundary only for the engine's own render (itself XS in Template::Stencil).
METHODS
new(\@pairs)
Compile the registry from [ [ $name, \%opts ], ... ]. Resolves, loads and instantiates each engine; the first is the default. Duplicate names, a class that will not load, or one missing new/render croak.
engine($name?)
The named (or default) engine instance; unknown names croak listing what is registered.
default
The default engine's name.
render($c, $template, \%data, %overrides)
A finished PSGI triplet around the engine's bytes, folding in any status and headers pending on the context $c (which may be undef). Overrides: status, type, engine.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)