All Versions
32
Latest Version
Avg Release Cycle
99 days
Latest Release
-

Changelog History
Page 1

  • v13.2.0

    // 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.1.0

    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 (including numbers), by [@pineapplemachine].
  • v4.0.1

    March 15, 2020

    ๐Ÿ›  Fixed

    • [#739]: Fix custom delimiters in nested partials, by [@aielo].
  • v4.0.0

    January 16, 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.

    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

    December 30, 2019

    ๐Ÿ›  Fixed

    • [#733]: Allow the CLI to use JavaScript views when the project has ES6 modules enabled, by [@eobrain].
  • v3.2.0

    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 be imported 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

    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

    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

    August 21, 2019

    ๐Ÿ›  Fixed

    Dev

    • โœ… #701: Fix test failure for Node 10 and above, by @andersk.
    • ๐Ÿ‘• #704: Lint all test files just like the source files, by @phillipj.
    • Start experimenting & comparing GitHub Actions vs Travis CI, by @phillipj.
  • v3.0.1

    November 11, 2018

    #679: Fix partials not rendering tokens when using custom tags, by @stackchain.