docsify-mustache / docsify-mustache.github.io

A Docsify plugin that allow preprocessing markdown documents with Mustache template engine.
https://docsify-mustache.github.io
MIT License
16 stars 6 forks source link

docsify-mustache

NPM License: MIT Issues

A Docsify plugin that allow preprocessing markdown documents with Mustache template engine. You can substitute variables in markdown documents using mustache syntax {{variable}} and {{variable.property}}. Variables can be load from various sources, including front matter section of markdown documents, external JSON or XML files and Docsify configuration.

Installation

Add following script tag to your index.html after docsify.

<script src="https://github.com/docsify-mustache/docsify-mustache.github.io/raw/master//cdn.jsdelivr.net/npm/docsify-mustache"></script>

Optionally add docsify-front-matter plugin to access markdown front matter variables.

<script src="https://github.com/docsify-mustache/docsify-mustache.github.io/raw/master//cdn.jsdelivr.net/npm/docsify/lib/plugins/front-matter.min.js"></script>

Options

data

You can load Mustache variables with data option. The value can be a string, object or array.

Example:

window.$docsify = {
  mustache: {
    data: [
      'doc/vars.json',
      'doc/pom.xml',
      {
        question: 'What is your favorite number?'
      }
    ]
  }
}

There is no way to access XML attributes, tag names used for hierarchy and for referring element's inner text.

package

The plugin loads package.json and make it available for Mustache as package variable. You can disable this feature setting noPackage option to true value:

window.$docsify = {
  mustache: {
    noPackage : true
  }
}

Documentation

Check the documentation site for more information.

License

This project is licensed under the MIT License. See the LICENSE for details.