Remove dictionary as placeholder type for named maps

This commit is contained in:
Daniel García Aubert
2017-04-25 19:40:12 +02:00
parent 7ea7a991aa
commit 07e507e1aa

View File

@@ -436,9 +436,11 @@ function _replaceVars (str, params) {
});
return str;
}
function isDictionary(val) {
function isObject(val) {
return ( _.isObject(val) && !_.isArray(val) && !_.isFunction(val));
}
TemplateMaps.prototype.instance = function(template, params) {
var all_params = {};
var phold = template.placeholders || {};
@@ -467,11 +469,6 @@ TemplateMaps.prototype.instance = function(template, params) {
throw new Error("Invalid css_color value for template parameter '" + k + "': " + val);
}
}
else if ( type === 'dictionary' ) {
if (!isDictionary(val)) {
throw new Error("Invalid dictionary value for template parameter '" + k + "': " + val);
}
}
else {
// NOTE: should be checked at template create/update time
throw new Error("Invalid placeholder type '" + type + "'");
@@ -484,7 +481,7 @@ TemplateMaps.prototype.instance = function(template, params) {
if (typeof layergroup.buffersize === 'string') {
layergroup.buffersize = Number(_replaceVars(layergroup.buffersize, all_params));
} else if (isDictionary(layergroup.buffersize)) {
} else if (isObject(layergroup.buffersize)) {
Object.keys(layergroup.buffersize).forEach(function(k) {
layergroup.buffersize[k] = Number(_replaceVars(layergroup.buffersize[k], all_params));
});