-
-
19 Sep 2006 11:00:10 UTC
- Distribution: Any-Renderer
- Module version: 1.011
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (846 / 383 / 0)
- Kwalitee
Bus factor: 0- 89.85% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (23.44KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- File::Find
- File::Spec
- Log::Trace
- Test::Assertions
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Any::Renderer::UrlEncoded - convert data structures into a UrlEncoded string
SYNOPSIS
use Any::Renderer; my %options = ('FlattenOptions' => {'HashDelimiter' => '->'}); my $format = "UrlEncoded"; my $r = new Any::Renderer ( $format, \%options ); my $data_structure = {...}; 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::UrlEncoded::available_formats ();
Also, determine whether or not a format requires a template with requires_template:
my $bool = Any::Renderer::UrlEncoded::requires_template ( $format );
DESCRIPTION
Any::Renderer::UrlEncoded renders a Perl data structure as a URI encoded string. Keys and values are escaped via URI::Escape::uri_escape. For example:
perl -MAny::Renderer -e "print Any::Renderer->new('UrlEncoded')->render({a => 1, b => [2,3]})"
results in:
a=1&b%3A1=3&b%3A0=2
This can be passed as a query string to a CGI script and reconstituted using Hash::Flatten::unflatten:
use CGI; use Hash::Flatten; my $data_structure = Hash::Flatten::unflatten( CGI->new()->Vars() );
NB. the top-level of the data structure must be a hashref.
FORMATS
- UrlEncoded
METHODS
- $r = new Any::Renderer::UrlEncoded($format,\%options)
-
$format
must beUrlEncoded
. See "OPTIONS" for a description of valid%options
. - $string = $r->render($data_structure)
-
The main method.
- $bool = Any::Renderer::UrlEncoded::requires_template($format)
-
False in this case.
- $list_ref = Any::Renderer::UrlEncoded::available_formats()
-
Just the one -
UrlEncoded
.
OPTIONS
- Delimiter
-
The character separating each key=value pair. Defaults to &. You might want to change to ; if you are embedding values in XML documents.
- FlattenOptions
-
A hashref passed to Hash::Flatten (see Hash::Flatten for the list of options it supports).
SEE ALSO
Hash::Flatten, URI::Escape, Any::Renderer
VERSION
$Revision: 1.11 $ on $Date: 2006/09/04 12:15:53 $ by $Author: johna $
AUTHOR
Matt Wilson and John Alden <cpan _at_ bbc _dot_ co _dot_ uk>
COPYRIGHT
(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
Module Install Instructions
To install Any::Renderer, copy and paste the appropriate command in to your terminal.
cpanm Any::Renderer
perl -MCPAN -e shell install Any::Renderer
For more information on module installation, please visit the detailed CPAN module installation guide.