This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
mustache-express with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Mustache Express lets you use Mustache and Express (at least version 3) together, including auto-loading partials.
var mustacheExpress = require('mustache-express'); // Register '.mustache' extension with The Mustache Express app.engine('mustache', mustacheExpress()); app.set('view engine', 'mustache'); app.set('views', __dirname + '/views');
The mustacheExpress method can take two parameters: the directory of the partials and the extension of the partials. When a partial is requested by a template, the file will be loaded from
path.resolve(directory, partialName + extension). By default, these values are determined by Express.
The return function has a
cache parameter that is an LRU Cache.
var engine = mustacheExpress(); var cache = engine.cache; // Caches the full file name with some internal data.