Sign Up for Free

RunKit +

Try any Node.js package right in your browser

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 grown-mustache with all npm packages installed. Try it out:

var grownMustache = require("grown-mustache")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grown-mustache v1.0.8

A template package extended mustache.js for providing Extension.


A template package extended mustache.js for providing Extension.


Run the following command.

npm i grown-mustache


Load the package as follows.

const GrownMustache = require('GrownMustache');


Basic usage

The basic usage is the same with mustache.js.

const gm = new GrownMustache({
    dir: './views',   // Optional
    extension: 'mst'  // Optional

gm.render('index', {
    message: 'Message'

index means ./views/index.mst in this case.
Or you also can use absolute path like /home/your/path/to/template/index.mst instead.


This feature is inspired by Blade.
As such, the usage is very similar.

First, create a layout file called layouts/app.mst in this case.

<!DOCTYPE html>
<html lang="ja">
    <div id="app">

Secondally, create a main file called index.mst.



  <title>{{ title }}</title>



  <h1>YOUR HEADING</h1>
  <div id="app">
      {{ message }}


Of course, you can use "mustache" symbolizing {{ *** }} in both of the files.

Finally, call render() as follows.

gm.render('index', {
    title: 'Test title',
    message: 'Test message'

Set parameter

You can use set() to set parameter(s) replacing with {{ *** }}.

gm.set('key1', 'value1');

or with object.

  key2: 'value2',
  key3: 'value3'

Use in Express app

Basic usage in Express.js

GrownMustache has a callback function for Express.
Use it as follows.

const GrownMustache = require('GrownMustache');

// Template
app.set('views', './views');
app.set('view engine', 'mst');

with Callback

express() can receive a callback function as the first argument.
It will be called before rendering.

app.engine('mst',, path, options) => {

    key1: 'value1',
    key2: 'value2',
    key3: 'value3'
  return gm; // must


Display mustache as is

This feature is shortcut of {{=<% %>=}} and <%={{ }}=%> that means showing as is.

@{{ test1 }}
@{{ test2 }}
@{{ test3 }}


{{ test1 }}
{{ test2 }}
{{ test3 }}

Include partial template

@include directive is also available to load a partial template as follows.



This package is licensed under the MIT License.
Copyright 2020 Sukohi Kuhoh


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free