X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=blobdiff_plain;f=README;h=6dc86bdf59957482f54b2b054110923f7f83a0b6;hp=eb4da93e24feb49ef3a407cc13891d73b8e83f06;hb=bf23e788f027c454711a8421b44945acbb2443b8;hpb=7c69490596e221b9d4be4d94de939429258ff7b3 diff --git a/README b/README index eb4da93..6dc86bd 100644 --- a/README +++ b/README @@ -1,65 +1,64 @@ NAME - URI::Template - Object for handling URI templates + URI::Template - Object for handling URI templates (RFC 6570) SYNOPSIS use URI::Template; + my $template = URI::Template->new( 'http://example.com/{x}' ); my $uri = $template->process( x => 'y' ); - # uri is a URI object with value 'http://example.com/y' - my %result = $template->deparse( $uri ); - # %result is ( x => 'y' ) + # or + + my $template = URI::Template->new(); + $template->template( 'http://example.com/{x}' ); + my $uri = $template->process( x => 'y' ); + + # uri is a URI object with value 'http://example.com/y' DESCRIPTION - This is an initial attempt to provide a wrapper around URI templates as - described at - http://www.ietf.org/internet-drafts/draft-gregorio-uritemplate-00.txt + This module provides a wrapper around URI templates as described in RFC + 6570: . INSTALLATION - To install this module via Module::Build: - - perl Build.PL - ./Build # or `perl Build` - ./Build test # or `perl Build test` - ./Build install # or `perl Build install` - - To install this module via ExtUtils::MakeMaker: - - perl Makefile.PL - make - make test - make install + perl Makefile.PL + make + make test + make install METHODS new( $template ) Creates a new URI::Template instance with the template passed in as the - first parameter. + first parameter (optional). + + template( $template ) + This method returns the original template string. If provided, it will + also set and parse a new template string. - as_string( ) - Returns the original template string. Also used when the object is - stringified. + variables + Returns an array of unique variable names found in the template (in the + order of appearance). - variables( ) - Returns an array of variable names found in the template. NB: they are - returned in random order. + expansions + This method returns an list of expansions found in the template. + Currently, these are just coderefs. In the future, they will be more + interesting. - process( %vars ) - Given a list of key-value pairs, it will URI escape the values and - substitute them in to the template. Returns a URI object. + process( \%vars ) + Given a list of key-value pairs or an array ref of values (for + positional substitution), it will URI escape the values and substitute + them in to the template. Returns a URI object. - process_to_string( %vars ) - Processes key-values pairs like the "process" method, but doesn't - inflate the result to a URI object. + process_to_string( \%vars ) + Processes input like the "process" method, but doesn't inflate the + result to a URI object. - deparse( $uri ) - Does some rudimentary deparsing of a uri based on the current template. - Returns a hash with the extracted values. +AUTHORS + * Brian Cassidy -AUTHOR - * Brian Cassidy + * Ricardo SIGNES COPYRIGHT AND LICENSE - Copyright 2007 by Brian Cassidy + Copyright 2007-2015 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.