Skip to main content

uri.templates

UriTemplates : d2/sdk/utils/uri.templates

Utility to help with parameter substiution for templatized URIs while turning it into an accessible URI.

Example (Sample use)

define([
'd2/sdk/utils/rest.linkrels',
'd2/sdk/utils/rest.resources',
'd2/sdk/utils/uri.templates'
], function(RestLinkrels, RestResources, UriTemplates){
'use strict';

var LINKREL_SEND_MAIL_CFG = 'http://identifiers.emc.com/linkrel/d2-sendmail-config';

function getMailConfigURL() {
var templateUrl = RestLinkrels.getLinkTemplate(RestResources.getCurrentRepository().get('links'), LINKREL_SEND_MAIL_CFG);
if (templateUrl) {
var params = {
'id': "default?"
}, template = new UriTemplates(templateUrl);

return template.fill(params);
}
}

return {
getMailConfigURL: getMailConfigURL
};
});

uriTemplates.fill(templateParams) ⇒ String

Substitute template parameters with their values.

Kind: instance method of UriTemplates
Returns: String - Returns the accessible URI.

ParamTypeDescription
templateParamsobject

An object hash containing key-value pairs. All matching keys from the URI is replaced with the key's corresponding value.

UriTemplates~UriTemplates

Kind: inner class of UriTemplates

new UriTemplates(templatizedUri)

ParamTypeDescription
templatizedUristring

Templatized URI, which will later be turned into accessible URI.