Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mustache-express

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mustache-express

Use mustache, including partials, in Express 3

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-23.72%
Maintainers
3
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 01 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc