Dancer::Plugin::FormattedOutput - Provide output in a variety of formats
Version 0.01
Similar in functionality to the standard Dancer serialisation routines, this module provides functions for serialising output to a variety of formats. Where it differs from the default Dancer functionality is that it:
use Dancer::Plugin::FormattedOutput; get '/some/route' => sub { my $data = get_data(); format "template" => $data; }; get '/some/other/route' => sub { my $data = get_data(); format $data; }; ...
The function "format" is automatically exported.
This function is exported in the calling namespace, and it manages the formatting of data into the various available formats.
It can be called as:
format($data) format("template_name" => $data); format($data, "default_format"); format("template_name", $data, "default_format");
The formatter for json. It appends the callback if any, and sets the content type to application/json or text/javascript as appropriate
The formatter for xml. It sets the content type, and does a basic transformation to xml.
The formatter for yaml. It sets the content type and does a basic transformation to yaml.
The formatter for text. It sets the content type, and, if the data is a hashref and has a key named "text", returns the value of that key. Otherwise it returns a Data::Dumper version of the data.
Alex Kalderimis, <alex kalderimis at gmail dot com>
<alex kalderimis at gmail dot com>
Please report any bugs or feature requests to bug-dancer-plugin-formattedoutput at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-FormattedOutput. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-dancer-plugin-formattedoutput at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Dancer::Plugin::FormattedOutput
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-FormattedOutput
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Dancer-Plugin-FormattedOutput
CPAN Ratings
http://cpanratings.perl.org/d/Dancer-Plugin-FormattedOutput
Search CPAN
http://search.cpan.org/dist/Dancer-Plugin-FormattedOutput/
Copyright 2011 Alex Kalderimis.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Dancer::Plugin::FormattedOutput, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::FormattedOutput
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::FormattedOutput
For more information on module installation, please visit the detailed CPAN module installation guide.