Skip to content

Multi-parameter Strings

Compare
Choose a tag to compare
@curran curran released this 11 Nov 11:03
· 100 commits to main since this release

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