Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.04 KB

.verb.md

File metadata and controls

60 lines (44 loc) · 1.04 KB

Usage

Use in your [base][] plugin to ensure that the plugin is registered on a valid instance.

var isValidInstance = require('{%= name %}');

function plugin(app) {
  if (!isValidInstance(app)) return;
  // do plugin stauff
}

API

{%= apidocs("index.js") %}

Examples

Collection instance

Return true if the instance is a [templates][] view-collection (views):

function plugin(collection) {
  if (!isValidInstance(collection, ['views'])) {
    // optionally return the plugin function so the plugin is re-tried on 
    // each instance until it finds the correct one
    return plugin;
  }
  // do plugin stauff
}

View instance

Return true if the instance is a [templates][] view:

function plugin(view) {
  if (!isValidInstance(view, ['view'])) {
    return plugin;
  }
  // do plugin stauff
}

View instance

Return true if the instance is either "app" or "collection":

function plugin(app) {
  if (!isValidInstance(app, ['app', 'collection'])) {
    return plugin;
  }
  // do plugin stauff
}