diff --git a/public/app/features/dashboard/partials/shareModal.html b/public/app/features/dashboard/partials/shareModal.html
index 8d76213de91..17f9d390c45 100644
--- a/public/app/features/dashboard/partials/shareModal.html
+++ b/public/app/features/dashboard/partials/shareModal.html
@@ -136,22 +136,23 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/public/app/features/templating/templateSrv.js b/public/app/features/templating/templateSrv.js
index 267454dbecb..6a2fa26ed6f 100644
--- a/public/app/features/templating/templateSrv.js
+++ b/public/app/features/templating/templateSrv.js
@@ -24,22 +24,18 @@ function (angular, _) {
this.updateTemplateData = function() {
this._values = {};
- this._texts = {};
_.each(this.variables, function(variable) {
- if (!variable.current || !variable.current.isNone && !variable.current.value) { return; }
-
- this._values[variable.name] = this.renderVariableValue(variable);
- this._texts[variable.name] = variable.current.text;
- }, this);
+ if (!variable.current || !variable.current.isNone && !variable.current.value) { return; }
+ this._values[variable.name] = variable.current.value;
+ }, this);
};
- this.renderVariableValue = function(variable) {
- var value = variable.current.value;
+ this.formatValue = function(value, format) {
if (_.isString(value)) {
return value;
} else {
- switch(variable.multiFormat) {
+ switch(format) {
case "regex values": {
return '(' + value.join('|') + ')';
}
@@ -89,22 +85,31 @@ function (angular, _) {
});
};
- this.replace = function(target, scopedVars) {
+ this.replace = function(target, scopedVars, format) {
if (!target) { return target; }
- var value;
+ var value, systemValue;
this._regex.lastIndex = 0;
return target.replace(this._regex, function(match, g1, g2) {
if (scopedVars) {
value = scopedVars[g1 || g2];
- if (value) { return value.value; }
+ if (value) {
+ return self.formatValue(value.value);
+ }
}
value = self._values[g1 || g2];
- if (!value) { return match; }
+ if (!value) {
+ return match;
+ }
- return self._grafanaVariables[value] || value;
+ systemValue = self._grafanaVariables[value];
+ if (systemValue) {
+ return self.formatValue(systemValue);
+ }
+
+ return self.formatValue(value, format);
});
};
diff --git a/public/test/specs/templateSrv-specs.js b/public/test/specs/templateSrv-specs.js
index 2b811244210..0728abc49cf 100644
--- a/public/test/specs/templateSrv-specs.js
+++ b/public/test/specs/templateSrv-specs.js
@@ -45,6 +45,22 @@ define([
});
});
+ describe.only('replace can pass multi / all format', function() {
+ beforeEach(function() {
+ _templateSrv.init([{name: 'test', current: {value: ['value1', 'value2'] }}]);
+ });
+
+ it('should replace $test with globbed value', function() {
+ var target = _templateSrv.replace('this.$test.filters', {}, 'glob');
+ expect(target).to.be('this.{value1,value2}.filters');
+ });
+
+ it('should replace $test with piped value', function() {
+ var target = _templateSrv.replace('this=$test', {}, 'pipe');
+ expect(target).to.be('this=value1|value2');
+ });
+ });
+
describe('render variable to string values', function() {
it('single value should return value', function() {
var result = _templateSrv.renderVariableValue({current: {value: 'test'}});