Re: URI Templates - optional variables?

Mike Schinkel scripsit:

> I'll throw my earlier suggestions to use a name and colon where the default
> is just {var}:
> 
> 	{<arg|var}  ->   {prefix:var,stuff}
> 	{>arg|var}  ->   {append:var,stuff}
> 	{,arg|var}  ->    {join:var,stuff}
> 	{&arg|var}  ->   {joinlist:var,stuff} 

The reason that Joe's proposal uses | (an earlier draft used :) to separate
stuff and var(s) is that | is illegal in URIs.  You need some way to escape
it in the template, such as \|, but this only comes up when you want an
explicit "%7E" sequence in the URI.

(Which reminds me:  Joe doesn't actually say that non-URI characters
appearing in the stuff should generate %-escapes in the result, but
that's the intention.)

You can't put the var first because there may be multiple vars.

-- 
John Cowan                                cowan@ccil.org
I amar prestar aen, han mathon ne nen,    http://www.ccil.org/~cowan
han mathon ne chae, a han noston ne 'wilith.  --Galadriel, LOTR:FOTR

Received on Monday, 15 October 2007 18:04:05 UTC