Plugin for Assemble which collects data from partials and groups it by key. Each value in the data hash has a list of associated partials.
This plugin was created to be used along with albogdano/handlebars-helper-mdpartial. When used together, these allow you to treat partials as mini pages and provide flexibility when working with partial data.
Use npm to install the package in your project's directory:
$ cd your-project
$ npm install assemble-partial-data --save-dev
To register the plugin explicitly in the Gruntfile:
grunt.initConfig({
assemble: {
options: {
// the "assemble-partial-data" npm module must also be listed in
// devDependencies for assemble to automatically resolve the plugin
plugins: ["assemble-partial-data", "foo/*.js"]
},
files: {
"dist/": ["src/templates/*.html"]
}
}
});
In your partials and pages use {{partialData}}
to access the partial data object
which contains the grouped data from all partials.
The YAML data is collected from each partial and grouped by key in a similar way to how Assemble groups categories
and tags
for pages.
Example data returned by {{partialData}}
:
"somedata": [
{
"value": "foo",
"partials": [
"part1",
"part2"
]
},
{
"value": "bar",
"partials": [
"part2",
"part3",
"part4"
]
}
]
- The
value
field contains the value of asomedata
. - The
partials
field contains a list of partials where this same piece of data was found.