[dancer-users] Dancer2::Plugin::SendAs
Russell Jenkins
russell.jenkins at strategicdata.com.au
Tue Oct 27 12:35:36 GMT 2015
Fellow Dancers,
At the Dancer conference in Vienna last week, Dancer2::Plugin::SendAs
was developed
and released. This plugin makes it easy to return either serialized
content or HTML
from a route. Here's the synopsis:
use Dancer2;
use Dancer2::Plugin::SendAs;
set serializer => 'YAML';
set template => 'template_toolkit';
# returns HTML content, though YAML serializer is configured
get '/html' => sub {
send_as html => template 'foo';
};
# returns JSON content, even with YAML serializer configured
get '/json/**' => sub {
send_as json => splat; # JSON, not YAML!
};
Sawyer and I briefly discussed if this should be core functionality
during the conference.
We decided to release it as a plugin and review moving it to core if
other Dancers find
this functionality useful.
Grab it from CPAN and give it a workout [1]. If send_as solves an issue
for your apps or
makes your code simpler, let us know (responding here if fine). If there
is enough [2]
feedback that this is generally useful, we'll make it core functionality.
Happy dancing!
Russell.
[1] I'm doing some post-conference travel, so haven't used it in anger
myself yet.
[2] Don't ask me to quantify "enough" ;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20151027/5c8e1fa6/attachment.html>
More information about the dancer-users
mailing list