Skip to content
Adriaan edited this page Nov 29, 2017 · 11 revisions

ember-data-url-templates is an ember addon to allow building urls with url templates instead of defining buildURL (as described in RFC #4).

Url templates are compiled with geraintluff/uri-templates, which fully implements RFC 6570 (level 4).

Documentation

Example

// adapters/comment
import Ember from "ember";
import DS from "ember-data";
import UrlTemplates from "ember-data-url-templates";

const { inject, computed } = Ember;

export default DS.RESTAdapter.extend(UrlTemplates, {
  urlTemplate: '{+host}/comments{/id}',
  createRecordUrlTemplate: '{+host}/users/{userId}/comments',

  session: inject.service(),

  urlSegments: {
    userId() {
      return this.get('session.userId'),
    }
  }
});