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 :
d2/sdk/utils/uri.templates
- instance
- .fill(templateParams) ⇒
String
- .fill(templateParams) ⇒
- inner
- instance
uriTemplates.fill(templateParams) ⇒ String
Substitute template parameters with their values.
Kind: instance method of UriTemplates
Returns: String
- Returns the accessible URI.
Param | Type | Description |
---|---|---|
templateParams | object | 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)
Param | Type | Description |
---|---|---|
templatizedUri | string | Templatized URI, which will later be turned into accessible URI. |