No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Organelle for mounting and rendering each of expressjs views/templates within directory recursively.


  "source": "node_modules/organic-express-staticpages",
  "reactOn": "ExpressServer",
  "pattern": "/**/*.jade",
  "path": "path/relative/to/cwd/pages",
  "exclude": undefined,
  "log": false,
  "emitReady": undefined

reactOn property

Should be either ExpressServer chemical with expected structure or array of chemicals where the first one is mapped as ExpressServer chemical.

path property

Directory which will be 'glob'-ed with pattern and each file will be mounted as get handler having this form:

app.get("path/to/page", function(req, res){

exclude property

Every file having exclude contents in its path will be ignored and not mounted. Support array or string input. Example:

having {
  exclude: "layouts"

will ignore files having `layouts` in its file path

haveing {
  exclude: ["layouts", "partials"]

will ignore files having `layouts` and/or `partials` in its file path

emitReady property

Once all pages are mounted and if value is present will be emitted as type of chemical

example usage

Given directory tree

 |- index.jade
 |- about.jade
 |- examples
  |- index.jade
  |- example1.jade
  |- example2.jade

Requests to the server render static context/pages templates:

  • GET / -> /context/pages/index.jade
  • GET /about -> /context/pages/about.jade
  • GET /examples -> /context/pages/examples/index.jade
  • GET /examples/example1.jade -> /context/pages/examples/example1.jade
  • GET /examples/example2.jade -> /context/pages/examples/example2.jade

using expressjs app setup

var jade = require("jade")
var express = require("express")

var app = express()
app.set("views", path.join(process.cwd(), "context/pages"))
app.set("view engine", "jade")
app.engine('jade', jade.__express);

// ...

// construct organelle's container plasma
var plasma = new (require("organic-plasma"))()

// construct organelle with dna
require("organic-express-staticpages")(plasma, {
  "reactOn": "ExpressServer",
  "path": "context/pages",
  "pattern": "**/*.jade",
  "log": true

// trigger organelle's reaction
plasma.emit({type: "ExpressServer", data: app})

// ...