admin-config
Advanced tools
Comparing version
@@ -39,4 +39,4 @@ import Application from "./Application"; | ||
application(name, baseApiUrl) { | ||
return new Application(name, baseApiUrl); | ||
application(name, debug) { | ||
return new Application(name, debug); | ||
} | ||
@@ -43,0 +43,0 @@ |
@@ -22,2 +22,3 @@ import stringUtils from "../Utils/stringUtils"; | ||
this.list = true; | ||
this._template = () => ''; | ||
} | ||
@@ -210,4 +211,18 @@ | ||
} | ||
getTemplateValue(data) { | ||
if (typeof(this._template) === 'function') { | ||
return this._template(data); | ||
} | ||
return this._template; | ||
} | ||
template(template) { | ||
if (!arguments.length) return this._template; | ||
this._template = template; | ||
return this; | ||
} | ||
} | ||
export default Field; |
@@ -6,21 +6,7 @@ import Field from "./Field"; | ||
super(name); | ||
this._template = function() { return ''; }; | ||
this._type = "template"; | ||
this._flattenable = false; | ||
} | ||
getTemplateValue(data) { | ||
if (typeof(this._template) === 'function') { | ||
return this._template(data); | ||
} | ||
return this._template; | ||
} | ||
template(template) { | ||
if (!arguments.length) return this._template; | ||
this._template = template; | ||
return this; | ||
} | ||
} | ||
export default TemplateField; |
{ | ||
"name": "admin-config", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -65,2 +65,22 @@ var assert = require('chai').assert; | ||
}); | ||
describe('template()', function() { | ||
it('should accept string values', function () { | ||
var field = new Field().template('hello!'); | ||
assert.equal(field.getTemplateValue(), 'hello!'); | ||
}); | ||
it('should accept function values', function () { | ||
var field = new Field().template(function () { return 'hello function !'; }); | ||
assert.equal(field.getTemplateValue(), 'hello function !'); | ||
}); | ||
}); | ||
describe('getTemplateValue()', function() { | ||
it('should return the template function executed with the supplied data', function() { | ||
var field = new Field().template(function (name) { return 'hello ' + name + ' !'; }); | ||
assert.equal(field.getTemplateValue('John'), 'hello John !'); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
167218
0.51%4258
0.4%