Ticket #121 (closed enhancement: fixed)

Opened 2 months ago

Last modified 2 months ago

client side forms framework: URI Templates

Reported by: karel Assigned to: mpo
Priority: minor Milestone: 0.3
Component: -- unknown -- Version: trunk
Keywords: uritemplate forms Cc:

Description (Last modified by karel)

Feature request for the URI Template functionality (in the client-side forms framework):

dot-separated template parts should be treated as nested object structures:

Current behaviour:
var t = new kp.Template("/test/{foo.id}");
t.expand({"foo": { "id": 5 }});  -> returns "/test/" instead of the more useful "/test/5"
t.expand({"foo.id": 5}); -> returns "/test/5" (which explains why the above does not work)

Suggested behaviour:
t.expand({"foo": { "id": 5}});  -> returns "/test/5";
To find the literal "foo.id" property, you should escape the dot in the template:
var t = new kp.template("/test/{foo\\.id}");
t.expand({"foo.id": 5}); -> returns "/test/5"

Change History

12/11/08 16:03:05 changed by karel

  • description changed.

17/11/08 16:05:01 changed by mpo

Implemented in revision [766] I did not opt for the \. escape notation but choose the more classic js ["property-name"].

Notes:

  1. Codewise this made it trivial to also support arrays, and the full range of ['xyz'] ["abc"] [123] next to sub.property.
  2. Additionally the routine works recursively to support any sub-sub combination of the above.
  3. For reasons of backwards compatibility, enforced though samples from the uri-template spec that we supported before we still support a uri-template {z.z} by first looking for context["z.z"] and only if not found for context.z.z
  4. An initial implementation through eval() was considered potentially harmful.
  5. Calling functions on context-objects was already supported before by just referencing the function-name without the (). Passing arguments to those functions, or further indexing the returned resulting object is (still) NOT supported.

17/11/08 16:05:21 changed by mpo

  • status changed from new to closed.
  • resolution set to fixed.