0

In the Assemble documentation there are instructions for loading up a Markdown file from a variable and rendering it with handlebars like this:

---
content: ../path/to/content.md
---
{{md  content }}

Is there any way to do this while using Jade instead of Handlebars?

I know you can use filters with includes in Jade like this: include:md path/to/markdown.md but I'm trying to load up a markdown file defined by a variable, as in the above example, and Jade doesn't support variables in includes.

Many thanks.

Community
  • 1
  • 1
bravokiloecho
  • 1,413
  • 5
  • 22
  • 39

2 Answers2

0

Have you tried using string interpolation with an include?

- var content = ../path/to/content.md
include #{content}

I don't have a setup to test this out, so I'm not sure if it'll work.

doowb
  • 3,372
  • 1
  • 17
  • 25
  • No, unfortunately that doesn't work. There's just no way round the fact that you can't pass a variable into a Jade include... – bravokiloecho Oct 07 '14 at 13:57
  • In assemble v0.6.0 we're using a different layout module. It will let you use variables during the layout processing (it uses lodash), then render the rest of the page through your chosen template engine (jade). I'll try to get a sample together to show what I mean. – doowb Oct 07 '14 at 18:30
  • Thanks doowb. I'd be curious to see what you mean. – bravokiloecho Oct 07 '14 at 20:14
0

After much head scratching I built a node package which enabled me to do what I want.

assemble-markdown-import (which borrowed heavily from another package: assemble-markdown-data) allows you to define a markdown file in the YAML data source like this:

# entry.yml
markdownFile: './text/about_julio_barnes.md'

The module will then read the Markdown file, convert it into HTML, and replace the YAML entry with the newly rendered HTML. You can then import the HTML directly into the Jade template like this:

div!=entry.markdownFile

So now there's no need to convert the Markdown with Jade and there's no need to use includes.

Full instructions are in the Github repo.

bravokiloecho
  • 1,413
  • 5
  • 22
  • 39