tmplat-mustache
v5.1.0
Published
Logic-less {{mustache}} templates with JavaScript
Maintainers
Readme
tmplat-mustache
A fork of mustache.js for the tmplat browser extension.
Install
Install using npm:
npm install tmplat-mustacheUsage
Rendering is asynchronous, so render returns a promise:
import TmplatMustache from 'tmplat-mustache';
const output = await TmplatMustache.render('Hello, {name}!', { name: 'Luke' });tmplat-mustache is very similar to mustache.js with the following differences:
- Uses
{unescaped}instead of{{{unescaped}}} - Comments, partials, sections (incl. inverted), and custom delimiters now use single curly braces
{&name}is used to escape instead of unescape, as is{{name}}- Treats a lone
{in text as the start of a tag, so literal braces need custom delimiters - Ignores case when looking up view properties
- Arrays are rendered as a comma-separated list based on their contents
- Objects are rendered as a comma-separated list based on their property values
- Functions are always called, so one can never be rendered as its own source code
- On a more technical note; the rendering is entirely asynchronous to support promises in the template context
It is published as an ESM-only package with TypeScript types included, and has no command line tool.
These changes make it perfect for usage within the tmplat browser extension.
Bugs
If you have any problems with this fork or would like to see changes currently in development you can do so here. Upstream features and issues are maintained separately here.
License
See LICENSE for more information on our MIT license.
