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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jade-browser-bis

v0.0.15

Published

express/connect middleware that serves jade compiled templates to the browser

Downloads

7

Readme

Jade Browser

Jade Browser build status

Middleware for express/connect to expose jade templates to the web browser. It provides a few additional features like express-like render function with partial handling.

var express = require('express')
  , jade_browser = require('jade-browser')
  , app = express.createServer();
  
app.use(jade_browser(url_endpoint, template_dir, options));

or for Express.js v3.x:

var express = require('express')
  , jade_browser = require('jade-browser')
  , app = express();
  
app.use(jade_browser(url_endpoint, template_dir, options));

Installation

$ npm install jade-browser

Features

  • Jade templates are served as compiled functions.
    • removes browser compatibility issues
    • increases speed of template execution
    • reduces file transfer size
  • ability to minify output
  • option to attach cache control
  • provides helpers for handling rendering/partials just like express.
  • relative path handling even from within partials.
  • ability to completely namespace to avoid any naming collisions on the browser.
  • partials inherit parent locals

Usage

In Node.js

As middleware jade-browser is simple to use.

var express = require('express')
  , jade_browser = require('jade-browser')
  , app = express.createServer();

app.use(jade_browser('/js/templates.js', '**', options));

Params

  • filename The filename of the resulting compiled templates file
  • patterns A single string or array of patterns used to glob for template files
  • options Options object, see below (optional)

Options

  • root The root of the views (default: __dirname)
  • namespace Namespace for the browser (default: 'jade')
  • minify Minifies the output (default: false)
  • maxAge Time in seconds to cache the results (default: 86400)
  • noCache Recompiles the output on every request (default: false)

Browser

jade.render('path/to/template', { values: for_template });

For direct access (for templates that have no need for partials).

jade.templates['path/to/template.jade'](locals);

Note: With render '.jade' extension is not required. Relative paths can be used in templates and in render function.

jade.render('path/../to/../test');

Credits

Large amounts of this code is inspired by TJ. Parts of express-expose and internal parts of express are recycled to make this happen. Contibuting docs part is taken from Mongoosastic.

Contributors

The list of contributors according to git shortlog -s -n:

  • 15 Conner Petzold (cpetzold)
  • 12 Nathan White (nw)
  • 9 Azat Mardanov
  • 4 Patrick Forringer
  • 2 Vincent Battaglia
  • 2 Arlo Breault
  • 2 RashFael
  • 1 Adrian Bravo (adrianbravo)

Contributing

Pull requests are always welcome as long as an accompanying test case is associated.

This project is configured to use git flow and the following conventions are used:

  • dev - represents current active development and can possibly be unstable.

  • master - pristine copy of repository, represents the currently stable release found in the npm index.

  • feature/** - represents a new feature being worked on

If you wish to contribute, the only requirement is to:

  • branch a new feature branch from develop (if you're working on an issue, prefix it with the issue number)
  • make the changes, with accompanying test cases
  • issue a pull request against develop branch

Although I use git flow and prefix feature branches with "feature/" I don't require this for pull requests... all I care is that the feature branch name makes sense.

Pulls requests against master or pull requests branched from master will be rejected.

Examples

Examples of good branch names:

  • 12-amd-support
  • feature/12-amd-support

Running Tests

In order to run the tests which are in test folder, you will need:

  • Node.js
  • NPM

With those installed, running npm install and ''npm test'' will run the tests.

License

(The MIT License)

Copyright (c) 2009-2011 Storify <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.