Gathering detailed insights and metrics for vinyl-view
Gathering detailed insights and metrics for vinyl-view
Gathering detailed insights and metrics for vinyl-view
Gathering detailed insights and metrics for vinyl-view
Extends vinyl with render and compile methods, and properties used for rendering templates.
npm install vinyl-view
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
17 Commits
3 Watchers
1 Branches
2 Contributors
Updated on Apr 12, 2021
Latest Version
2.0.1
Package Id
vinyl-view@2.0.1
Size
4.52 kB
NPM Version
3.10.10
Node Version
6.9.5
Published on
Feb 09, 2017
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Extends vinyl with render and compile methods, and properties used for rendering templates.
Install with npm:
1$ npm install --save vinyl-view
Use the same way you would use a vinyl file:
1var View = require('vinyl-view'); 2var view = new View({path: 'foo'});
Create an instance of View
. Optionally pass a default object to use.
Params
view
{Object}Example
1var view = new View({ 2 path: 'foo.html', 3 contents: new Buffer('...') 4});
Synchronously compile a view.
Params
locals
{Object}: Optionally pass locals to the engine.returns
{Object} View
: instance, for chaining.Example
1var view = page.compile(); 2view.fn({title: 'A'}); 3view.fn({title: 'B'}); 4view.fn({title: 'C'});
Synchronously render templates in view.content
.
Params
locals
{Object}: Optionally pass locals to the engine.returns
{Object} View
: instance, for chaining.Example
1var view = new View({content: 'This is <%= title %>'}); 2view.renderSync({title: 'Home'}); 3console.log(view.content);
Asynchronously render templates in view.content
.
Params
locals
{Object}: Context to use for rendering templates.Example
1view.render({title: 'Home'}, function(err, res) { 2 //=> view object with rendered `content` 3});
Create a context object from locals
and the view.data
and view.locals
objects. The view.data
property is typically created from front-matter, and view.locals
is used when a new View()
is created.
This method be overridden either by defining a custom view.options.context
function
to customize context for a view instance, or static View.context function to customize
context for all view instances.
Params
locals
{Object}: Optionally pass a locals object to merge onto the context.returns
{Object}: Returns the context object.Example
1var page = new View({path: 'a/b/c.txt', locals: {a: 'b', c: 'd'}}); 2var ctx = page.context({a: 'z'}); 3console.log(ctx); 4//=> {a: 'z', c: 'd'}
Returns true if the view is the given viewType
. Returns false
if no type is assigned. When used with vinyl-collections, types are assigned by their respective collections.
Params
type
{String}: (renderable
, partial
, layout
)Example
1var view = new View({path: 'a/b/c.txt', viewType: 'partial'})
2view.isType('partial');
Define a custom static View.context
function to override default .context
behavior. See the context docs for more info.
Params
locals
{Object}returns
{Object}Example
1// custom context function 2View.context = function(locals) { 3 // `this` is the view being rendered 4 return locals; 5};
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. MIT
This file was generated by verb-generate-readme, v0.4.2, on February 08, 2017.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More