nunjucks-markdown
A nunjuck extension that adds a markdown tag. This plugin allows you to choose your own markdown renderer.
Install
npm install nunjucks-markdown --save
Usage
Register the extension with nunjucks
var nunjucks =markdown =marked = ;var env = nunjucks;// The second argument can be any function that renders markdownmarkdown;
Add markdown to your templates
{% markdown %}
Hello World
===========
# Do stuff
{% endmarkdown %}
You can also provide the markdown tag with a template to render
{% markdown "post.md" %}
Note: This method doesn't require a closing tag
As you would expect, you can add tags inside your markdown tag
{% markdown %}
{% include 'post1.md' %}
{% include 'post2.md' %}
{% endmarkdown %}
Using with Gulp
Gulp requires a little more explicit settings than standard npm. See https://mozilla.github.io/nunjucks/api.html#custom-tags
see example-gulpefile.js based on https://gist.github.com/kerryhatcher/1382950af52f3082ecdc668bba5aa11b
var nunjucks =markdown =marked =gulpnunjucks = ;var templates = 'src/templates'; //Set this as the folder that contains your nunjuck filesvar env = templates;// The second argument can be any function that renders markdownmarkdown;gulp;
Markdown Options
Nunjucks-markdown doesn't require you to use any particular markdown renderer. If you were to use marked here's a good example of how it could be configured.
var marked = ;marked;markdown;
For more information configuration options, checkout marked.