New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-view

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-view

Express view class for synthetic views.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
4
Weekly downloads
 
Created
Source

Express View

Build Status

express-view ships with a custom express view class implementation which allows to control res.render() calls. Normally, express along with some specific view engine can do the work of compiling and rendering templates on the server side, but express-view span that to support the use of compiled-to-javascript templates that were already provisioned in memory thru a filesystem abstraction component like locator.

Usage

var express = require('express'),
    expview = require('express-view'),
    app = express();

app.set('locator', myLocatorObj); // filesystem abstraction layer
expview.extend(app);

With the code above, there is not need to define anything else in express in terms of engine, or path to views, or anything else, all that is irrelevant since express-view will completely take over the express's template resolution process, and will drive it thru myLocatorObj abtraction, which means you can call res.render('foo') in your middleware, and express-view will resolve foo template. express-view will try to find foo template thru the locator instance API, and it will fallback to the regular express implementation if the template is not found, in case you need to mix-in synthetic views and traditional views.

Layout

You can also define a default layout:

app.set('layout', 'name-of-the-layout-template');

If you use layout as above, or just by providing the layout value when calling res.render('foo', { layout: 'bar' }), express-view will resolve the view, render it, and the result of that operation will be passed into the layout render thru a context variable called outlet, this is similar to emberjs. In a handlebars template, you will define the outlet like this:

<div>{{{outlet}}}</div>

Bundles

Locator organizes templates per bundle (which are usually NPM dependencies that contain compiled templates). By default, the root bundle in your locator object will be used to resolve templates, and you have the ability to specify which bundle should be used to resolve the template::

res.render('foo', {
    bundle: 'name-of-the-bundle'
});

If the template foo is not found in the specified bundle, express-view will look into the root bundle, or fallback to the traditional express view resolution process.

More info

Under the example folder you can see a more detailed example of how to use express-view.

Also, for more information about the new feature in express that powers express-view, read this:

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

Contribute

See the CONTRIBUTING.md file for more information.

Keywords

FAQs

Package last updated on 26 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc