npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

seneca-views

v0.3.7

Published

A views engine for senecajs that renders views as a microservice. Allows views to be referenced by plugin and name rather than file location making it compatible with multi-process, multi-machine microservices.

Readme

Seneca Views Engine

A microservice plugin for Senecajs that can be used to render views. Currently uses the JADE rendering engine but new engines are trivial to add.

Installation

npm install seneca-views

Usage

To use this plugin add the following line to your seneca.js program. seneca.use('views');

You can add a view to the views engine by calling the following command:

seneca.act({ role: "views", cmd: "add", name: view.name, plugin: view.plugin, ext: view.ext, template: view.template}, ...)

In this command, ext means "file extension" which can be used to deduce the rendering engine. You can also pass in an "engine" signature to override the default deduced engine (ie: using html with swig).

Plugin refers to the namespace of the views for your application. Using something like "home" for frontend views and "admin" for backend views as your "plugin" allows you to create multiple base views that can be rendered from anywhere.

The "template" value is a buffer or string that contains the template itself. Using seneca entities this can be stored in-memory (using mem-store) or in a persistence engine (ie: database or file system).

= JADE considerations The JADE rendering engine is the only one currently pre-packaged into the system. Jade extends and includes work by specifying the layout in the form of "pluginName/templateName". For example, if you're extending a common "admin" layout.jade file for all of your backend pages, you can extend that layout by using the following line: extends admin/layout

The same works for includes:

include home/_footer

NOTE: the underscore here is just a convention for partials and is not required - any plugin / template value can be placed here.

The views in jade are not tied to the filesystem so views can be added and rendered across microservices.

Example Adding Views to the Views Engine

It's recommended that you add views in the "init" method of your seneca plugin.

To add all of view from a specified folder, you can use the following snippet.

This example uses the async npm module and the "path" npm module.

    seneca.add({init:pluginName}, function(args, done) {
        fs.readdir(path.join(__dirname, "/views"), function(err, files) {
            if (err) {
                done(err);
            } else {
                async.each(files, function(file, cb) {
                    if (err) {
                        cb(err);
                    } else {
                        var view = {};
                        view.plugin = pluginName;
                        view.ext = require('path').extname(file);
                        view.name = require('path').basename(file, view.ext);
                        view.path = path.join(__dirname, "/views", file);
                        view.template = fs.readFileSync(view.path);
                        seneca.act({
                            role: "views",
                            cmd: "add", 
                            name: view.name,
                            plugin: view.plugin,
                            ext: view.ext,
                            template: view.template
                        }, function(err, result) {
                            console.log(result);
                            if (err) {
                                cb(err);
                            } else {
                                cb();
                            }
                        });
                    }
                }, function(err) {
                    if (err) {
                        done(err);
                    } else {
                        done();
                    }
                });
            }
        }); 
    });

Example with Express

You can use the views engine to render express views from senecajs by using the standard seneca.act method:

router.get('/dashboard', routeMiddleware.restrictToLoggedIn, function(req, res){
    req.seneca.act({
        "role": "views",
        "cmd": "render",
        "plugin": "admin",
        "name": "dashboard",
        "locals": {
            user: req.seneca.user
        }
    }, function(err, result) {
        if (err) {
            console.log(err);
            res.status(err.status).send(err.why);
        } else {
            res.send(result.html);
        }
    });
    //   res.render('dashboard.jade',{locals:{user:req.seneca.user}});
});