async-mustache

Asyncronous view functions

Usage no npm install needed!

<script type="module">
  import asyncMustache from 'https://cdn.skypack.dev/async-mustache';
</script>

README

async-mustache.js - Asyncronous view functions

A wrapper around https://github.com/janl/mustache.js/ providing asyncronous view functions

Usage

Node:

var Mustache = require('mustache');
var AsyncMustache = require('async-mustache')({mustache: Mustache});

var view = {
    async: AsyncMustache.async(function (text, render, callback) {
        setTimeout(function () {
            callback(null, render(text));
        }, 0);
    }))
};

AsyncMustache.render('{{#async}}async-{{/async}}mustache.js', view).then(function (output) {
    console.log(output); // async-mustache.js
});

Browser:

<script src="mustache.js"></script>
<script src="async-mustache.js"></script>
<script>
var asyncMustache = require('async-mustache')({mustache: Mustache});
//Use it
</script>

LICENSE

MIT