[dancer-users] Dancer2::Plugin::SendAs

Zahir Lalani ZahirLalani at oliver.agency
Tue Oct 27 18:19:56 GMT 2015

Very nice!

From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of Russell Jenkins
Sent: 27 October 2015 12:36
To: dancer-users at dancer.pm
Subject: [dancer-users] Dancer2::Plugin::SendAs

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!

[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/935a560e/attachment.html>

More information about the dancer-users mailing list