New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

middleware-render

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

middleware-render

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

render middleware

middleware to render arbitrary views. This middleware can be used with all existing template engines.

Usage

Middleware called before render should populate the req.loaded object with data that the view should present to the client render will send the output of view req.loaded to the client

Example

jsonView = (params) -> JSON.stringify params

router.get '/resource',
    (req, res, next) ->
        req.loaded =
            foo: 'bar'
            fitz: [1..10]
        next()
    render jsonView

// will render `'{"foo":"bar","fitz":[1,2,3,4,5,6,7,8,9,10]}'` to the
// client

Credits

This middleware was implemented with snd while hacking together on a project. I cleaned up the code and added some tests.

FAQs

Package last updated on 19 Jun 2012

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