Total Pageviews

Tuesday 27 May 2014

expressSite


"Addon" nodejs module for expressjs framework providing lightweight 'pages' support, or other called client-side app single-page apps.
Includes:
  • packageme (https://github.com/camplight/packageme/) for packaging directories of files needed by client-side apps
  • Backbone-like class implementation of client-side app (a Page).
  • consolidate.js for server-side template engines

Usage

add "expressSite" to dependencies in package.json add your prefered template engine, for example "jade" to dependencies in package.json add "consolidate" to dependencies in package.json
Create app.js with the following example code:
var app = require("expressSite");

var cons = require("consolidate");
app.engine('jade', cons.jade);

app.set('view engine', 'jade');

app.configure(function(){
  app.useExpressSiteMiddleware();
});

app.addPage({
  url: "/",
  content: "./templates/index",
  variables: {
    title: "Index Page"
  }
});

app.listen(8000, function(){
  console.log("listening on 8000");
});
Create client and client/templates folders.
Place your layout template containing these as minimum at /client/templates/layout.jade:
!!! html
head
  !{javascripts}
  !{stylesheets}
body
  !{views}
  !{content}
{javascripts}, {stylesheets} & {views} will be replaced by expressSite with appropiate path to packaged javascripts, stylesheets & views. {content} will be replaced with the content of the pages using that layout.
Create /client/templates/index.jade file with content as you like.
Launch the application or refer to the demo for additional usage examples.

from https://github.com/camplight/expressSite