Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioningarrow-up-right.

4.0.0arrow-up-right / 16 January 2020

Majority of using projects don't have to worry by this being a new major version.

TLDR; if your project manipulates Writer.prototype.parse | Writer.cache directly or uses .to_html(), you probably have to change that code.

This release allows the internal template cache to be customised, either by disabling it completely or provide a custom strategy deciding how the cache should behave when mustache.js parses templates.

const mustache = require('mustache');

// disable caching
Mustache.templateCache = undefined;

// or use a built-in Map in modern environments
Mustache.templateCache = new Map();

Projects that wanted to customise the caching behaviour in earlier versions of mustache.js were forced to override internal method responsible for parsing templates; Writer.prototype.parse. In short, that was unfortunate because there is more than caching happening in that method.

We've improved that now by introducing a first class API that only affects template caching.

The default template cache behaves as before and is still compatible with older JavaScript environments. For those who wants to provide a custom more sopisiticated caching strategy, one can do that with an object that adheres to the following requirements:

{
  set(cacheKey: string, value: string): void
  get(cacheKey: string): string | undefined
  clear(): void
}

Added

Removed

3.2.1arrow-up-right / 30 December 2019

Fixed

3.2.0arrow-up-right / 18 December 2019

Added

Using mustache.js as an ES module

To stay backwards compatible with already using projects, the default exposed module format is still UMD. That means projects using mustache.js as an CommonJS, AMD or global scope module, from npm or directly from github.com can keep on doing that for now.

For those projects who would rather want to use mustache.js as an ES module, the mustache/mustache.mjs file has to be imported directly.

Below are some usage scenarios for different runtimes.

Modern browser with ES module support

Node.jsarrow-up-right (>= v13.2.0 or using --experimental-modules flag)

ES Module support for Node.js will be improved in the future when Conditional Exportsarrow-up-right is enabled by default rather than being behind an experimental flag.

More info in Node.js ECMAScript Modules docsarrow-up-right.

3.1.0arrow-up-right / 13 September 2019

Added

Fixed

3.0.3arrow-up-right / 27 August 2019

Added

Fixed

3.0.2arrow-up-right / 21 August 2019

Fixed

Dev

3.0.1arrow-up-right / 11 November 2018

3.0.0arrow-up-right / 16 September 2018

We are very happy to announce a new major version of mustache.js. We want to be very careful not to break projects out in the wild, and adhering to Semantic Versioningarrow-up-right we have therefore cut this new major version.

The changes introduced will likely not require any actions for most using projects. The things to look out for that might cause unexpected rendering results are described in the migration guide below.

A big shout out and thanks to @raymond-lamarrow-up-right for this release! Without his contributions with code and issue triaging, this release would never have happened.

Major

Minor

Migrating from mustache.js v2.x to v3.x

Rendering properties of primitive types

We have ensured properties of primitive types can be rendered at all times. That means Array.length, String.length and similar. A corner case where this could cause unexpected output follows:

View:

Template:

Output with v3.0:

Output with v2.x:

Caching for templates with custom delimiters

We have improved the templates cache to ensure custom delimiters are taken into consideration for the cache. This improvement might cause unexpected rendering behaviour for using projects actively using the custom delimiters functionality.

Previously it was possible to use Mustache.parse() as a means to set global custom delimiters. If custom delimiters were provided as an argument, it would affect all following calls to Mustache.render(). Consider the following:

The above illustrates the fact that Mustache.parse() made mustache.js cache the template without considering the custom delimiters provided. This is no longer true.

We no longer encourage using Mustache.parse() for this purpose, but have rather added a fourth argument to Mustache.render() letting you provide custom delimiters when rendering.

If you still need the pre-parse the template and use custom delimiters at the same time, ensure to provide the custom delimiters as argument to Mustache.render() as well.

2.3.2arrow-up-right / 17 August 2018

This release is made to revert changes introduced in 2.3.1arrow-up-right that caused unexpected behaviour for several users.

Minor

2.3.1arrow-up-right / 7 August 2018

Minor

Dev

Docs

2.3.0arrow-up-right / 8 November 2016

Minor

Dev

Docs

Dependencies

2.2.1arrow-up-right / 13 December 2015

Fixes

2.2.0arrow-up-right / 15 October 2015

Added

Changed

Fixes

Dependencies

  • chai -> 3.3.0

  • eslint -> 1.6.0

2.1.3arrow-up-right / 23 July 2015

Added

Changed

Fixed

2.1.2arrow-up-right / 17 June 2015

Added

2.1.1arrow-up-right / 11 June 2015

Added

Fixed

2.1.0arrow-up-right / 5 June 2015

2.0.0arrow-up-right / 27 Mar 2015

1.2.0arrow-up-right / 24 Mar 2015

1.1.0arrow-up-right / 18 Feb 2015

1.0.0arrow-up-right / 20 Dec 2014

0.8.2arrow-up-right / 17 Mar 2014

  • Supporting Bower through a bower.json file.

0.8.1arrow-up-right / 3 Jan 2014

  • Fix usage of partial templates.

0.8.0arrow-up-right / 2 Dec 2013

  • Remove compile* writer functions, use mustache.parse instead. Smaller API.

  • Throw an error when rendering a template that contains higher-order sections and the original template is not provided.

  • Remove low-level Context.make function.

  • Better code readability and inline documentation.

  • Stop caching templates by name.

0.7.3arrow-up-right / 5 Nov 2013

  • Don't require the original template to be passed to the rendering function when using compiled templates. This is still required when using higher-order functions in order to be able to extract the portion of the template that was contained by that section. Fixes #262arrow-up-right.

  • Performance improvements.

0.7.2arrow-up-right / 27 Dec 2012

  • Fixed a rendering bug (#274arrow-up-right) when using nested higher-order sections.

  • Better error reporting on failed parse.

  • Converted tests to use mocha instead of vows.

0.7.1arrow-up-right / 6 Dec 2012

0.7.0arrow-up-right / 10 Sep 2012

  • Rename Renderer => Writer.

  • Allow partials to be loaded dynamically using a callback (thanks @TiddoLangerakarrow-up-right for the suggestion).

  • Fixed a bug with higher-order sections that prevented them from being passed the raw text of the section from the original template.

  • More concise token format. Tokens also include start/end indices in the original template.

  • High-level API is consistent with the Writer API.

  • Allow partials to be passed to the pre-compiled function (thanks @fallenicearrow-up-right).

  • Don't use eval (thanks @cweiderarrow-up-right).

0.6.0arrow-up-right / 31 Aug 2012

Last updated