1. All dependencies are outdated.
I tested it with latest dependencies and all tests were successfully passed.
2. The default data option requires object type.
The default data option requires an object. We can instead check for whether an object or a path string is passed. In the case of data object it will be merge to default data while in the case of path it should first parse json and then merge parsed data with default data.
3. Handle template inheritance and markdown.
This could be treated as a feature request and can be avoided if needed .
If a file with front-matter is triggered and it contains a layout object then it should be handled differently. The front-matter should be merged with default data as something like page object so that front-matter data could be accessed in parent templates using {{ page.title }} etc.
Further the body contents should be wrapped with extends and block tags so that we can get layout from front-matter and render current file with desired layout file. Also If current file is markdown that we should parse it with marked before rendering.
According to Nunjucks Changelog, starting from 3.0.0 released on Nov 5,
base templates can no longer see vars set in templates that inherit them.
Hence parsing data objects from front-matter and merging it with data passed before rendering template will allow using that data in parent templates.
I have created PR #56 with suggested changes.
If there is something I missed, please correct me. Thanks in advance.
Closing this as it seems like maintainer is no longer listening to us. Although I have published a plugin with changes made in my pull request and some fixes to help myself.
I am creating this issue for a few reasons
1. All dependencies are outdated. I tested it with latest dependencies and all tests were successfully passed.
2. The default data option requires object type. The default data option requires an object. We can instead check for whether an object or a path string is passed. In the case of data object it will be merge to default data while in the case of path it should first parse json and then merge parsed data with default data.
3. Handle template inheritance and markdown.
If a file with front-matter is triggered and it contains a
layout
object then it should be handled differently. The front-matter should be merged with default data as something likepage
object so that front-matter data could be accessed in parent templates using{{ page.title }}
etc. Further the body contents should be wrapped withextends
andblock
tags so that we can get layout from front-matter and render current file with desired layout file. Also If current file is markdown that we should parse it with marked before rendering. According to Nunjucks Changelog, starting from 3.0.0 released on Nov 5,Hence parsing data objects from front-matter and merging it with data passed before rendering template will allow using that data in parent templates.
I have created PR #56 with suggested changes.
If there is something I missed, please correct me. Thanks in advance.