So it seems quite simple (yet I cannot make it work)..
I would like to set a custom property in the options object in Assemble within my Gruntfile and would like to access it from one of my partials context in YML.
So say I have a folder in my project with all my documentation in .md-files.. (app/src/documentation)
In the options object I would like to do something like:
assemble: {
options: {
jsDoc: '<%= yeoman.app %>/src/documentation',
},
And then within one of my partials I would like to do the following:
---
title: Headings
status: In progress
tabs:
- tab: html
- tab: css
- tab: js
- tab: description
- tab: links
jsDoc: filename.md
---
<!-- Show markdown documentation -->
{{md jsDoc}}
Right now I get an error saying :
Warning: Cannot call method 'indexOf' of undefined Use --force to continue.
Can anyone give any hints/ideas on how to get this to work?
Bonus info: To make things a little more complicated, I would actually like to use {{md jsDoc}} in another partial (using my custom helper), where I have access to my other partials context..
I've made a couple of gists showing the code I have right now.
It's located here:
https://gist.github.com/dgsunesen
Thanks in advance! Dan
If you're only using the partial matter inside it's own partial, then it's pretty simple...
---
title: Headings
status: In progress
tabs:
- tab: html
- tab: css
- tab: js
- tab: description
- tab: links
jsDoc: "<%= jsDoc %>/filename.md"
---
<!-- Show markdown documentation -->
{{md headings.jsDoc}}
You can use lodash templates to combine the main jsDoc
property with the one in the partial. Then reference based on the name of the partial {{headings.jsDoc}}
But from looking at your helper code, it looks like you want jsDoc
to be set inside another partial (that's dynamically added), then used inside the sgComponent
file.
To do that, I think instead of doing the process content you'll need to actually combine the variables from the main options with the jsDoc
in the partial. If you try doing process content with the lodash, it'll get into a loop because of how you're getting the front matter in the helper.
Also, make sure parameters are being passed in properly because that indexof
error could be coming from glob
or yfm
.
Hope this helps some.