Releases: datavis-tech/json-templates
Releases · datavis-tech/json-templates
Multi-parameter Strings
This release adds support for
- strings containing multiple inner parameters, and
- handling of extra white space around parameters.
For example:
it("should compute template for a string with multiple inner parameters", function() {
var template = parse("Hello {{firstName}} {{lastName}}, how are you ?");
assert.deepEqual(template.parameters, [{ key: "firstName" }, { key: "lastName" }]);
assert.equal(template({ firstName: "Jane", lastName: "Doe" }), "Hello Jane Doe, how are you ?");
});
it("should handle extra whitespace", function() {
var template = parse("Hello {{firstName }} {{ lastName}}, how are you ?");
assert.deepEqual(template.parameters, [{ key: "firstName" }, { key: "lastName" }]);
assert.equal(template({ firstName: "Jane", lastName: "Doe" }), "Hello Jane Doe, how are you ?");
});
See #6
Templatable keys
Added support for templatable keys. See PR #3
Inner parameters
This version introduces support for parameters within strings.
For example, now the following will work:
var template = parse("Hello {{foo}}, how are you ?");
assert.deepEqual(template.parameters, [{ key: "foo" }]);
assert.equal(template({ foo: "john" }), "Hello john, how are you ?");