get-view: Assemble View Utility

2.0.0 · abandoned · verified Sun Apr 19

get-view is a utility designed to retrieve 'view' objects from collection structures, primarily within the `assemble` and `templates` ecosystems. It works with collections of Vinyl files, offering flexible lookup mechanisms including by path, basename, filename, relative path, or a custom function. The package is currently stable at version 2.0.0, but it appears to be abandoned, with no updates or activity detected for approximately 8 years (as of April 2026). It was designed for Node.js environments `>=6` and is tightly coupled with the older `assemble` and `templates` frameworks, which are also no longer actively maintained. As such, while functional, users should consider its long-term viability and potential lack of modern feature support or security updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `templates`, add pages to its collection, and then use `get-view` to retrieve specific views based on various lookup criteria such as filename, relative path, or a custom filtering function.

const templates = require('templates');
const getView = require('get-view');

// Initialize templates instance
const app = templates();
app.create('page');

// Add some pages to the collection
app.page('foo', { content: 'this is foo' });
app.page('bar.md', { content: 'this is bar' });
app.page('a/b/c/baz.md', { content: 'this is baz', base: 'a' });
app.page('test/fixtures/templates/a.tmpl');

// Get a view by filename 'baz'
const viewByFilename = getView(app.views.pages, 'baz');
console.log('View by filename:', viewByFilename ? viewByFilename.basename : 'Not found');

// Get a view by relative path 'b/c/baz.md'
const viewByRelative = getView(app.views.pages, 'b/c/baz.md');
console.log('View by relative path:', viewByRelative ? viewByRelative.basename : 'Not found');

// Get a view using a custom lookup function
const viewByFunction = getView(app.views.pages, function(view) {
  return view.stem === 'foo';
});
console.log('View by custom function:', viewByFunction ? viewByFunction.basename : 'Not found');

view raw JSON →