Skip to content
Plugin for Assemble for gathering data from partials
HTML JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
examples
.gitignore
.jshintrc
Gruntfile.js
LICENSE
README.md
assemble.json
index.js
package.json

README.md

assemble-partial-data NPM version

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.

Installation

Use npm to install the package in your project's directory:

$ cd your-project
$ npm install assemble-partial-data --save-dev

Register the plugin

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"]
    }
  }
});

Usage

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 a somedata.
  • The partials field contains a list of partials where this same piece of data was found.

License

MIT License

Something went wrong with that request. Please try again.