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.
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>
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.
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
}
}
Check the documentation site for more information.
This project is licensed under the MIT License. See the LICENSE for details.