Any::Renderer::JavaScript::Anon - renders anonymous JavaScript data structure
use Any::Renderer; my %options = ( 'VariableName' => 'myvariable' ); my $format = "JavaScript::Anon"; my $r = new Any::Renderer ( $format, \%options ); my $data_structure = [...]; # arbitrary structure code my $string = $r->render ( $data_structure );
You can get a list of all formats that this module handles using the following syntax:
my $list_ref = Any::Renderer::JavaScript::Anon::available_formats ();
Also, determine whether or not a format requires a template with requires_template:
my $bool = Any::Renderer::JavaScript::Anon::requires_template ( $format );
Any::Renderer::JavaScript::Anon renders any Perl data structure passed to it as a JavaScript anonymous data structure.
A more compact equivalent to the JavaScript format, using anonymous structures in the assignment.
perl -MAny::Renderer -e "print Any::Renderer->new('Javascript::Anon')->render({a => 1, b => [2,3]})"
results in:
var script_output = { a: 1, b: [ 2, 3 ] };
Use the format 'JSON' to return completely anonymous data structures - i.e. with no leading "var script_output = " and no trailing ";"
perl -MAny::Renderer -e "print Any::Renderer->new('JSON')->render({a => 1, b => [2,3]})"
{ a: 1, b: [ 2, 3 ] }
See "FORMATS" for a description of valid values for $format. See "OPTIONS" for a description of valid %options.
$format
%options
The main method.
False in this case.
See "FORMATS" for a list.
Name of the javascript variable that the new data structure is to be assigned to. Defaults to script_output. Does not apply when using JSON format.
script_output
JSON
Data::JavaScript::Anon, Any::Renderer
$Revision: 1.9 $ on $Date: 2006/08/21 08:30:24 $ by $Author: johna $
Matt Wilson <matthew.wilson@bbc.co.uk>
(c) BBC 2006. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
To install Any::Renderer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Any::Renderer
CPAN shell
perl -MCPAN -e shell install Any::Renderer
For more information on module installation, please visit the detailed CPAN module installation guide.