Registry / web-framework / get-view

get-view

JSON →
library2.0.0jsnpmunverified

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.

npm install get-view
INSTALL
IMPORT
SIG · GET-VIEW
G
get-view
web-frameworkjavascriptv2.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getView
✓ const getView = require('get-view');
This is the original and primary method for importing `getView` in Node.js CommonJS environments. The module directly exports the function.
getView
✓ import getView from 'get-view';
✗ import { getView } from 'get-view';
When consuming this CommonJS package in an ES module (ESM) context, Node.js's CJS-ESM interop allows importing the CommonJS default export using `import getView from 'get-view';`. Attempting named imports (`{ getView }`) will result in `undefined`.
module object
✓ const moduleExport = require('get-view'); // moduleExport is the function itself
✗ const { getView } = require('get-view');
The `get-view` module directly exports the function. It does not export an object with named properties. Therefore, destructuring `require` will result in `getView` being undefined.

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');
Debug
Known issues
breakingIn `v2.0`, the order of arguments for the `getView` function was reversed. The collection of views is now passed as the first argument, and the lookup value (key or function) as the second.
fix
Ensure `getView(collection, lookupValue)` is used, not `getView(lookupValue, collection)`.
affects: >=2.0
breakingAs of `v2.0`, `get-view` no longer matches views using glob patterns by default. If glob matching is required, a dedicated glob matcher function must be passed as the second argument.
fix
If you relied on glob matching, implement it externally and pass a function as the second argument to `getView` that performs the glob matching.
affects: >=2.0
gotchaThe `get-view` package, along with its related projects like `assemble` and `templates`, appears to be abandoned. It has not received updates for approximately 8 years. This means there will be no new features, compatibility updates for newer Node.js versions or ecosystems, or security patches.
fix
Consider migrating to actively maintained alternatives for static site generation or build processes. If continued use is necessary, be aware of potential vulnerabilities and compatibility issues, and consider forking for self-maintenance.
affects: >=2.0
Errors
Common errors & fixes
TypeError: getView is not a function
Attempting to use ES module named import (`import { getView } from 'get-view';`) for a CommonJS-only package, or incorrect destructuring of the `require` call.
fix
For CommonJS, use `const getView = require('get-view');`. For ESM interop, use `import getView from 'get-view';`.
TypeError: The "collection" argument must be an object, or null
Incorrect argument order for `getView` function, passing the lookup key as the first argument instead of the collection object, which was a breaking change in v2.0.
fix
Ensure the first argument is the collection object (e.g., `app.views.pages`) and the second is the lookup key or function: `getView(collection, lookupValue)`.
No view found for [...]
The provided lookup key or custom function did not match any view in the collection. This could be due to an incorrect key, or expecting glob matching which is no longer default in v2.0.
fix
Verify the lookup key (path, basename, filename, relative) exactly matches a view's property. If using a custom function, ensure its logic correctly identifies the target view. If globbing, implement and pass a glob-matching function explicitly.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
get-view — npm install get-view · libregistry