Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :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.

like image 919
Šime Vidas Avatar asked Dec 29 '13 17:12

Šime Vidas


1 Answers

You can include markdown files using the :md filter modifier.

eg.

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

Language Reference: https://pugjs.org/language/includes.html#including-filtered-text

like image 129
arnorhs Avatar answered Oct 12 '22 14:10

arnorhs