mustache-express
Use mustache, including partials, in Express 3
Last updated 10 months ago by syn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mustache-express 
SYNC missed versions from official npm registry.

Build Status

Mustache Express lets you use Mustache and Express (at least version 3) together, including auto-loading partials.

Usage

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');

Parameters

The mustacheExpress method can take three parameters: the directory of the partials, the extension of the partials, and an optional array of tags. 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.

Example: If you want to create a folder for your partials in the view directory like so:

view
  ├── partials
  │   ├── footer.mst
  │   └── header.mst
  ├── error.mst
  └── index.mst

You should configure your view engine while passing the following parameters:

/**
 * Pass the path for your partial directory and
 * the extension of the partials within the mustache-express method
 */
app.engine('mst', mustache(VIEWS_PATH + '/partials', '.mst'));

Properties

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.

Current Tags

  • 1.3.0                                ...           latest (10 months ago)

17 Versions

  • 1.3.0                                ...           10 months ago
  • 1.2.8                                ...           2 years ago
  • 1.2.7                                ...           2 years ago
  • 1.2.6                                ...           2 years ago
  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.2.3                                ...           7 years ago
  • 0.2.2                                ...           7 years ago
  • 0.2.1                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago

Copyright 2014 - 2017 © taobao.org |