JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22306
  • Score
    100M100P100Q144131F
  • License MIT

Compose elements from multiple applications into one.

Package Exports

  • base-compose

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-compose) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-compose NPM version Build Status

Compose elements from multiple applications into one.

Install

Install with npm:

$ npm i base-compose --save

Usage

This plugin requires an "app" using the base-generators to be able to lookup generators to compose. Some of the composition handler methods require an "app" that is inherited from templates or use specific plugins. The methods and plugins are specified in the api section.

var compose = require('base-compose');
app.use(compose());

API

.compose

Setup a composition by passing in an array of generators to compose elements. If a generator cannot be found, an error will be thrown.

Params

  • generators {Array}: Array of generators to be composed.
  • returns {Object}: Instance of CompositionHandler

Example

var composition = app.compose(['a', 'b', 'c']);

// most of the time, use chaining
app.compose(['a', 'b', 'c'])
  .data()
  .options()
  .views();

Composition Handler API

.data

Merge the cache.data object from each generator onto the app.cache.data object. This method requires the .data() method from templates.

Params

  • key {String}: Optionally pass a key to merge from the data object.
  • returns {Object}: Returns this for chaining

Example

a.data({foo: 'a'});
b.data({foo: 'b'});
c.data({foo: 'c'});

app.compose(['a', 'b', 'c'])
  .data();

console.log(app.cache.data);
//=> {foo: 'c'}

.engines

Merge the engines from each generator into the app engines. This method requires the .engine() methods from templates.

  • returns {Object}: Returns this for chaining

Example

app.compose(['a', 'b', 'c'])
  .engines();

.helpers

Merge the helpers from each generator into the app helpers. This method requires the .helper method from templates.

  • returns {Object}: Returns this for chaining

Example

app.compose(['a', 'b', 'c'])
  .helpers();

.options

Merge the options from each generator into the app options. This method requires using the base-option plugin.

Params

  • key {String}: Optionally pass a key to merge from the options object.
  • returns {Object}: Returns this for chaining

Example

a.option({foo: 'a'});
b.option({foo: 'b'});
c.option({foo: 'c'});

app.compose(['a', 'b', 'c'])
  .options();

console.log(app.options);
//=> {foo: 'c'}

.tasks

Copy the specified tasks from each generator into the app tasks. Task dependencies will also be copied. This method requires using the base-task plugin.

  • returns {Object}: Returns this for chaining

Example

app.compose(['a', 'b', 'c'])
  .tasks(['foo', 'bar', 'default']);

.views

Copy the view collections and loaded views from each generator to the app. This method requires using an "app" inherited from templates.

  • returns {Object}: Returns this for chaining

Example

app.compose(['a', 'b', 'c'])
  .views();

.iterator

Iterates over the specified generators and only calls fn on existing generators. Function passed into the iterator will be invoked with the current generator being iterated over (gen) and the app passed into the original function. No binding is done within the iterator so the function passed in can be safely bound.

Params

  • generators {Array}: Optional array of generator names to be looked up and iterated over.
  • fn {Function}: Function invoked with generator currently being iterated over and the app.
  • returns {Object}: Returns this for chaining

Example

app.compose(['a', 'b', 'c'])
  .iterator(function(gen, app) {
    // do work
    app.data(gen.cache.data);
  });

// optionally, a different array of generator names may be passed as the first argument.
app.compose(['a', 'b', 'c'])
  .iterator(['d', 'e', 'f'], function(gen, app) {
    // do work
  });
  • assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage
  • assemble-core: The core assemble application with no presets or defaults. All configuration is left to the… more | homepage
  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more | homepage
  • update: Easily keep anything in your project up-to-date by installing the updaters you want to use… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb on February 03, 2016.