Šime Vidas Šime Vidas - 2 years ago 118
Javascript Question

Is it possible to include external files when using Jade’s :markdown filter?

I'm building an Express.js Node app and using Jade templates. Jade provides a

filter which enables embedding Markdown code inside Jade:

h1 This is Jade
## And this is Markdown
h3 Back in Jade

(Note: In order to use this filter you have to npm install a Markdown engine, e.g.
npm install marked --save
. You don't have to
this module within your Express app, but it has to be installed.)

So, embedding Markdown within Jade works fine. However, I would like to keep my Markdown in separate files and include them in Jade templates dynamically. I've tried this and it does not work:

include ../path/to/markdown/file.md

command is treated as source code instead of being interpreted as a command. Is it possible to inject Markdown from external files within the

Please don't provide workarounds! I know how to work around this issue. I want to know if the
filter is compatible with external Markdown files.

Answer Source

You can include markdown files using the :md filter modifier


    include:md ../path/to/markdown/file.md

I found it by looking at the filtered include test: https://github.com/visionmedia/jade/blob/master/test/cases/include-filter.jade

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download