ember-data-url-templates is an addon to allow building urls with url templates instead of
defining buildURL as described in RFC #4.
ember-data-url-templates is under early development. Feedback is welcome, and of course, so are pull-requests.
Url templates are compiled with geraintluff/uri-templates, which fully implements RFC 6570.
ember install ember-data-url-templates
ember generate ember-data-url-templatesember-data-url-templates makes use of a few features in ember-data that are still in canary (1.0.0-beta.17+canary). Namely:
- findQuery passes query to
buildURL(introduced in https://github.com/emberjs/data/commit/ab93c00571d62504cb997d3a7944aa430575856f) - Pass requestType to
buildURL(introduced in https://github.com/emberjs/data/commit/ff35ee78bfac058afb7a715a5dfc5760218cc05c)
// adapters/comment
import DS from "ember-data";
import UrlTemplates from "ember-data-url-templates";
extend default DS.RESTAdapter(UrlTemplates, {
findUrlTemplate: '{+host}/comments/{id}',
urlTemplate: '{+host}/posts/{postId}/comments{/id}'
});The entire query from findQuery can be included in the url with {?query*}.
findQueryUrlTemplate: '/posts{?query*}'Or, selective keys from findQuery can be used in the url.
findQueryUrlTemplate: '/blog/{category}{/year,month}'git clonethis repositorynpm installbower install
ember testorember test --server
Here is a short list of things I'd like to support:
- Optionally specify a template for each requestType
- Use a template provided by the API (like
links) - Use the query from
findQueryto fill the template