Commit 35f55cab by Torkel Ödegaard

fix(templating): improved detection of nested template variables, fixes #4986, fixes #4987

parent 0201ac24
# 3.0.2 Stable (unreleased)
* **Templating**: Fixed issue mixing row repeat and panel repeats, fixes [#4988](https://github.com/grafana/grafana/issues/4988)
* **Templating**: Fixed issue detecting dependencies in nested variables, fixes [#4987](https://github.com/grafana/grafana/issues/4987), fixes [#4986](https://github.com/grafana/grafana/issues/4986)
# 3.0.1 Stable (2016-05-11)
......
......@@ -97,7 +97,8 @@ function (angular, _) {
if (!str) {
return false;
}
return str.indexOf('$' + variableName) !== -1 || str.indexOf('[[' + variableName + ']]') !== -1;
var match = this._regex.exec(str);
return match && (match[1] === variableName || match[2] === variableName);
};
this.highlightVariablesAsHtml = function(str) {
......
......@@ -190,6 +190,11 @@ define([
expect(contains).to.be(true);
});
it('should not find it if only part matches with $var syntax', function() {
var contains = _templateSrv.containsVariable('this.$ServerDomain.filters', 'Server');
expect(contains).to.be(false);
});
it('should find it with [[var]] syntax', function() {
var contains = _templateSrv.containsVariable('this.[[test]].filters', 'test');
expect(contains).to.be(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment