uri-templates 0.4 javascript implementation feedback

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

uri-templates 0.4 javascript implementation feedback

Marc Portier
Hi all,

Finally got round at this javascript implementation of
http://tools.ietf.org/html/draft-gregorio-uritemplate-04

(minus the partial syntax and some more testing)


Anyway, it is open at:
https://github.com/marc-portier/uri-templates

It wraps inside JQuery and comes with tests up in QUnit.
(JQuery dependency currently limited to the handy $.extend and $.isFunction)


Must say getting my head around things asked more time then I initially
expected: clarity and elegance of the syntax and explanation did hide
quite some more special cases then I would of have thought of.

One case I still haven't ironed out, to the extend I'm liking my
solution more :) is this:

> tested pattern: {;list}
> Expected: ";val1,val2,val3"
> Result:  ";list=val1,val2,val3"
>
> tested pattern: {;keys}
> Expected: ";key1,val1,key2,val2"
> Result:  ";keys=key1,val1,key2,val2"
>

which in my mind (and implementation) follows more closely the line of
thinking in:

>
> tested pattern: {?list}
> Expected: "?list=val1,val2,val3"
>
> tested pattern: {?keys}
> Expected: "?keys=key1,val1,key2,val2"
>

the consistency I see is this: both ; and ? operators deal with named
parameters, in unexploded form the values are wrapped up in one string,
but still expect value.


best regards,

-marc=
PS: The link to the promised js implementation from
http://code.google.com/p/uri-templates/wiki/Implementations points to
some reserved space at www.snellspace.com  (I remember grabbing a 0.3
implmentation from James' blog way back, that is somewhat maintained
over here: )


Reply | Threaded
Open this post in threaded view
|

Re: uri-templates 0.4 javascript implementation feedback

Roy T. Fielding
This is an old comment that I missed ...

On Apr 28, 2011, at 12:17 AM, Marc Portier wrote:

> Hi all,
>
> Finally got round at this javascript implementation of
> http://tools.ietf.org/html/draft-gregorio-uritemplate-04
>
> (minus the partial syntax and some more testing)
>
>
> Anyway, it is open at:
> https://github.com/marc-portier/uri-templates
>
> It wraps inside JQuery and comes with tests up in QUnit.
> (JQuery dependency currently limited to the handy $.extend and $.isFunction)
>
>
> Must say getting my head around things asked more time then I initially expected: clarity and elegance of the syntax and explanation did hide quite some more special cases then I would of have thought of.
>
> One case I still haven't ironed out, to the extend I'm liking my solution more :) is this:
>
>> tested pattern: {;list}
>> Expected: ";val1,val2,val3"
>> Result:  ";list=val1,val2,val3"
>>
>> tested pattern: {;keys}
>> Expected: ";key1,val1,key2,val2"
>> Result:  ";keys=key1,val1,key2,val2"
>>
>
> which in my mind (and implementation) follows more closely the line of thinking in:
>
>>
>> tested pattern: {?list}
>> Expected: "?list=val1,val2,val3"
>>
>> tested pattern: {?keys}
>> Expected: "?keys=key1,val1,key2,val2"
>>
>
> the consistency I see is this: both ; and ? operators deal with named parameters, in unexploded form the values are wrapped up in one string, but still expect value.

Yes, I made the same mistake in draft 05 for the Level 4 examples
but got it right in the section on Default.  I'll fix it for 06.

....Roy