{"id":10942,"library":"get-view","title":"get-view: Assemble View Utility","description":"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.","status":"abandoned","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/get-view","tags":["javascript","assemble","collection","file","find","get","gulpfriendly","match","view"],"install":[{"cmd":"npm install get-view","lang":"bash","label":"npm"},{"cmd":"yarn add get-view","lang":"bash","label":"yarn"},{"cmd":"pnpm add get-view","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the original and primary method for importing `getView` in Node.js CommonJS environments. The module directly exports the function.","symbol":"getView","correct":"const getView = require('get-view');"},{"note":"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`.","wrong":"import { getView } from 'get-view';","symbol":"getView","correct":"import getView from 'get-view';"},{"note":"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.","wrong":"const { getView } = require('get-view');","symbol":"module object","correct":"const moduleExport = require('get-view'); // moduleExport is the function itself"}],"quickstart":{"code":"const templates = require('templates');\nconst getView = require('get-view');\n\n// Initialize templates instance\nconst app = templates();\napp.create('page');\n\n// Add some pages to the collection\napp.page('foo', { content: 'this is foo' });\napp.page('bar.md', { content: 'this is bar' });\napp.page('a/b/c/baz.md', { content: 'this is baz', base: 'a' });\napp.page('test/fixtures/templates/a.tmpl');\n\n// Get a view by filename 'baz'\nconst viewByFilename = getView(app.views.pages, 'baz');\nconsole.log('View by filename:', viewByFilename ? viewByFilename.basename : 'Not found');\n\n// Get a view by relative path 'b/c/baz.md'\nconst viewByRelative = getView(app.views.pages, 'b/c/baz.md');\nconsole.log('View by relative path:', viewByRelative ? viewByRelative.basename : 'Not found');\n\n// Get a view using a custom lookup function\nconst viewByFunction = getView(app.views.pages, function(view) {\n  return view.stem === 'foo';\n});\nconsole.log('View by custom function:', viewByFunction ? viewByFunction.basename : 'Not found');","lang":"javascript","description":"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."},"warnings":[{"fix":"Ensure `getView(collection, lookupValue)` is used, not `getView(lookupValue, collection)`.","message":"In `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.","severity":"breaking","affected_versions":">=2.0"},{"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.","message":"As 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.","severity":"breaking","affected_versions":">=2.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"For CommonJS, use `const getView = require('get-view');`. For ESM interop, use `import getView from 'get-view';`.","cause":"Attempting to use ES module named import (`import { getView } from 'get-view';`) for a CommonJS-only package, or incorrect destructuring of the `require` call.","error":"TypeError: getView is not a function"},{"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)`.","cause":"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.","error":"TypeError: The \"collection\" argument must be an object, or null"},{"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.","cause":"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.","error":"No view found for [...]"}],"ecosystem":"npm"}