helper-aggregate

{{aggregate}} handlebars helper. Inlines content from multiple files optionally using wildcard (globbing/minimatch) patterns, extracts YAML front matter to pass to context for each file. Accepts compare function as 3rd parameter for sorting inlined files.

{{aggregate}}

{{aggregate}} handlebars helper. Inlines content from multiple files optionally using wildcard (globbing/minimatch) patterns, extracts YAML front matter to pass to context for each file. Accepts compare function as 3rd parameter for sorting inlined files.

In the root of your project, run the following in the command line:

npm i helper-aggregate --save-dev
{{aggregate 'path/to/*.hbs'}}

In your Gruntfile, simply add helper-aggregate to the helpers property in the Assemble task or target options:

grunt.initConfig({
  assemble: {
    options: {
      helpers: ['helper-aggregate']
    }
    ...
  }
});

With that completed, you may now use the {{aggregate}} helper in your Assemble project.

Type: String Default value: \n

The separator to append after each inlined file.

Set options as hash arguments.

---
chapter: 1
---
{{aggregate 'path/to/*.hbs' sep="\n\n\n"}}

Pass Assemble options into the helper.

In your project's Gruntfile, options for the {{aggregate}} helper can be defined in the Assemble task options:

grunt.initConfig({
  assemble: {
    options: {
      aggregate: {
        sep: '\n',
        compare_fn: 5
      }
    }
    ...
  }
});

Note that the options are defined in the custom property, aggregate, not on the options object itself.

Jon Schlinkert

Licensed under the MIT License Copyright (c) Jon Schlinkert, contributors.