Skip to content

Releases: datavis-tech/json-templates

Multi-parameter Strings

11 Nov 11:03
Compare
Choose a tag to compare

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

11 Nov 10:58
Compare
Choose a tag to compare

Added support for templatable keys. See PR #3

Inner parameters

06 Oct 15:56
Compare
Choose a tag to compare

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 ?");

Many thanks to @t00f for this change (#1).