Changelog History
Page 1
-
v13.2.0 Changes
// index.mjs import mustache from 'mustache/mustache.mjs' console.log(mustache.render('Hello {{name}}!', { name: 'Santa' })) // Hello Santa!
ES Module support for Node.js will be improved in the future when Conditional Exports 0๏ธโฃ is enabled by default rather than being behind an experimental flag.
๐ More info in Node.js ECMAScript Modules docs.
-
v4.2.0 Changes
March 28, 2021โ Added
- ๐ฆ [#773]: Add package.json
exports
field, by [@manzt].
- ๐ฆ [#773]: Add package.json
-
v4.1.0 Changes
December 06, 2020โ Added
- [#764]:
render()
now recognizes a config object argument, by [@pineapplemachine].
๐ Fixed
- [#764]: Ask custom
escape
functions to escape all types of values (includingnumber
s), by [@pineapplemachine].
- [#764]:
-
v4.0.1 Changes
March 15, 2020๐ Fixed
- [#739]: Fix custom delimiters in nested partials, by [@aielo].
-
v4.0.0 Changes
January 16, 2020Majority 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.
0๏ธโฃ 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
- [#731]: Allow template caching to be customised, by [@AndrewLeedham].
โ Removed
- ๐ [#735]: Remove
.to_html()
, by [@phillipj].
-
v3.2.1 Changes
December 30, 2019๐ Fixed
- [#733]: Allow the CLI to use JavaScript views when the project has ES6 modules enabled, by [@eobrain].
-
v3.2.0 Changes
December 18, 2019โ Added
- [#728]: Expose ECMAScript Module in addition to UMD (CommonJS, AMD & global scope), by [@phillipj] and [@zekth].
Using mustache.js as an ES module
0๏ธโฃ 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 beimport
ed directly.Below are some usage scenarios for different runtimes.
๐ป Modern browser with ES module support
<!-- index.html --> <script type="module"> import mustache from "https://unpkg.com/[email protected]/mustache.mjs" console.log(mustache.render('Hello {{name}}!', { name: 'Santa' })) // Hello Santa! </script>
-
v3.1.0 Changes
September 13, 2019โ Added
- ๐ #717: Added support .js files as views in command line tool, by @JEStaubach.
๐ Fixed
- ๐ #716: Bugfix for indentation of inline partials, by @yotammadem.
-
v3.0.3 Changes
August 27, 2019โ Added
- [#713]: Add test cases for custom functions in partials, by [@wol-soft].
๐ Fixed
- [#714]: Bugfix for wrong function output in partials with indentation, by [@phillipj].
-
v3.0.2 Changes
August 21, 2019