Closed zephraph closed 9 years ago
@tedw I've got an experimental implementation of this in the include branch if you'd like to test it out. I'd love some feedback.
I'd like this functionality as well. The experimental implementation uses fs.readFileSync(url)
however I believe this doesn't take into account the root directories which can be set in the Nunjucks environment. The built-in include
, extends
, import
and call
do take care of this, but couldn't find directly how.
Could you simply use {% markdown %}{% include "path/to/content.md" %}{% endmarkdown %}
or is content with the markdown blog not parsed (in time)?
It doesn't actually work that way. Everything inside the markdown blocks is treated as raw markdown code. I'll look into using the import functionality in the markdown include block though, that's actually a pretty exciting idea.
@zephraph Finally got around to testing this out—works great! Only issue is that it seems to fail with relative file paths, which I think is the issue @jbmoelker was raising.
I'll try to work on this tomorrow if I have time. I'd really like to have this functionality as well.
Okay, so I just added a test in to verify, but adding and include tag inside the markdown tag now works. I still fully intent to add argument support but I need to figure out where the relative path variable is saved. I should have that tonight or tomorrow if all goes well.
Again, sorry for being absent guys! Hope the update works well for you, if you have any issues let me know.
The implementation was easier than expected.
Includes can be done with {% markdown "content.md" %}
and it will respect nunjuck's configured relative path.
Happy New Year! Thanks for making the update. I just tested it out, but it's still looking in the root directory. I'm using 'gulp-nunjucks-render' instead of 'nunjucks' which might have something to do with it.
Strange. If you have time could you try to write a test that replicates your failure? If not I can try to do it soon, but it'll probably be next week at the earliest because I'm slammed at work right now.
I'm going to close this again and open up a new issue for this problem.
So sorry for not getting back to you sooner! Work got very busy for me and I lost track of this.
I was finally able to test again and can confirm the issue has been resolved! I think the issue I had previously was because I was using an older syntax for 'marked' settings. Once I switched to the marked.setOptions() method everything worked great.
Good! I'm glad it works for you.
I updated it again after that. The latest version doesn't even require marked. You just provide your own rendering function.
Should be able to include markdown files.
As suggested by @tedw