URI::Template(3pm)

πŸ“¦
version 0.24 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– URI::Template πŸ’–

okay bestie, sit down, because this is URI::Template, a whole 3pm Perl manual page, and it's literally about gluing URI templates together like the icon you are. ✨


🌸 NAME 🌸

URI::Template β€” an object for handling URI templates, specifically the ones from RFC 6570. periodt. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

here's the glow-up in code form, no cap:

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, if you wanna skip the whole object era and just get a URI right now:

use URI::Template ':template_process'

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so this module is a wrapper. it wraps around URI templates, which are described in RFC 6570, which lives right here: http://tools.ietf.org/html/rfc6570. it's giving "I'm the friendly lil interface between you and a spec that is lowkey intimidating". obsessed. πŸ’…


✨ INSTALLATION ✨

the classic four-step main character routine:

perl Makefile.PL
make
make test
make install

πŸ’… METHODS πŸ’…

new( $template )

makes you a brand new URI::Template instance. you pass the template in as the first parameter... but here's the tea: that parameter is optional, so you can also just vibe with an empty one and set it later. 🫢

template( $template )

this one hands you back the original template string. and if you actually give it a template, it will also set it and parse it as a fresh new template string. two jobs, one method, we love a multitasker. 🌈

variables

returns an array of the unique variable names it found in the template β€” and yes, they come back in the order of appearance</c>, because we respect chronology in this house. πŸ’œ

expansions

returns a list of the expansions found in the template. right now they're just coderefs β€” kind of dry, kind of mysterious β€” but apparently in the future they will be more interesting. so like, watch this space bestie. 😭

process( \%vars )

feed it a list of key-value pairs, or an array ref of values if you're doing positional substitution. it will URI escape all those values and swap them into the template. you get back a URI object. iconic behaviour tbh. ✨

process_to_string( \%vars )

does the exact same processing as process, except it doesn't inflate the result into a URI object β€” you just get the string. for the girlies who want their data raw. πŸ“


🌟 EXPORTED FUNCTIONS 🌟

template_process( $template => \%vars )

this is literally the same thing as URI::Template->new($template)->process(\%vars) but shorter, and it's "usefull" (their spelling, not mine, we support them) for quickly and easily "genrating" a nice URI form parameters. it returns a URI object. πŸ’–

template_process_as_string( $template => \%vars )

same as the one above, but obviously, it returns a string instead. 🌸


πŸ‘‘ AUTHORS πŸ‘‘

  • Brian Cassidy <bricas@cpan.org> πŸ’œ
  • Ricardo SIGNES <rjbs@cpan.org> πŸ’œ

🧚 CONTRIBUTERS 🧚

(yes, that's how the section is spelled, we're not touching it, it's part of the lore πŸ’€)

  • Theo van Hoesel <Th.J.v.Hoesel@THEMA-MEDIA.nl> ✨

Copyright 2007-2018 by Brian Cassidy. 🫢

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go forth and remix, bestie.


and that's the whole page!! no notes. go build some URIs. πŸ¦‹βœ¨

perl v5.36.0 Β· 2022-10-13 Β· URI::Template, page 3pm β€” mwah, slay, bye πŸ‘‘πŸ’…

πŸ“¦ where this page comes from