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

Viewed 3794

I'm building an Express.js Node app and using Jade templates. Jade provides a :markdown filter which enables embedding Markdown code inside Jade:

h1 This is Jade
:markdown
  ## 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 require() 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:

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

The include command is treated as source code instead of being interpreted as a command. Is it possible to inject Markdown from external files within the :markdown filter?

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

3 Answers

First, run this command:

npm install marked --save

Then, do this:

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