URI::Template(3pm)

URI::Template3pm

Object for handling uri templates (rfc 6570)

Usage

    use URI::Template;
   
    my $template = URI::Template->new( 'http://example.com/{x}' );
    my $uri      = $template->process( 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'

or

    use URI::Template ':template_process'
    
    my $uri = template_process ( 'http://example.com/{x}', x => 'y' );

Overview

This module provides a wrapper around URI templates as described in RFC 6570: <http://tools.ietf.org/html/rfc6570>.

Installation

    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 (optional).

template( $template )

This method returns the original template string. If provided, it will also set and parse a new template string.

variables

Returns an array of unique variable names found in the template (in the order of appearance).

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 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 input like the "process" method, but doesn't inflate the result to a URI object.

Exported functions

template_process( $template => \%vars )

This is the same as "URI::Template->new($template)->process(\%vars)" But shorter, and usefull for quick and easy genrating a nice URI form parameters.

Returns an URI object

template_process_as_string( $template => \%vars )

Same as above, but obviously, returns a string.

Contributers

•

Theo van Hoesel <[email protected]>

Releases

9 releases since Debian 5.0 (Lenny); the text changed 6 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9
  6. 10–11
  7. 12–13

Authors

•

Brian Cassidy <[email protected]>

•

Ricardo SIGNES <[email protected]>

From liburi-template-perl 0.24-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.