Skip to content

Instantly share code, notes, and snippets.

@jorgepedret
Created December 10, 2013 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgepedret/7897038 to your computer and use it in GitHub Desktop.
Save jorgepedret/7897038 to your computer and use it in GitHub Desktop.
Using Harp as a library

Using Harp as a library

There are two ways to pass data to the templates: 1) with _data.json and 2) with _harp.json. See the examples below for the correct way of doing it.

Directory Strucutre

/node_modules
/public
  /_data.json
  /_harp.json
  /index.jade
/package.json
/server.js
{
"index": {
"title": "Hello World"
}
}
{
"globals": {
"foo": "bar"
}
}
h1= title
h2= foo
{
"dependencies": {
"express": "3.x",
"harp": "0.10.x"
}
}
var express = require("express");
var harp = require("harp");
var app = express();
app.configure(function(){
app.use(express.static(__dirname + "/public"));
app.use(harp.mount(__dirname + "/public"));
});
app.listen(9001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment