Saturday, August 18, 2012


Derby.js – Integrating Twitter Bootstrap into your Application


As I’ve mentioned in a previous post, I’m a big fan of Twitter Bootstrap.
Lately I’ve been playing been with JavaScript and Derby. I want to integrate bootstrap with the POC site I’m building, and the creators of Derby have already figured out a way to do this.
Step 1: Add a dependency to the derby-ui-boot package, which is a Derby component library based on Twitter Bootstrap.
1
2
3
4
5
6
7
8
9
10
{
....
  "dependencies": {
    "derby": "*",
    "derby-ui-boot": "*",
    "express": "3.0.0beta4",
    "gzippo": ">=0.1.7"
  },
....
}
Step 2: Update your project with the downloaded ui-boot code
This is as simple as running
npm update
in your project folder, which will read package.json, and download any missing dependencies (like the derby-ui-boot entry you just added).
Step 3: Add the derby-ui-boot component to your project.
At the top of your application JavaScript (for me, this is the file located at /lib/app/index.js), after your var derby = require("derby"); line, add the following line of code to your file:
1
2
var derby = require("derby");
derby.use(require('derby-ui-boot'));
Step 4: Profit!
That should be it for you. When you load your application up, the default twitter bootstrap css and js should have loaded. To correctly style your application, you’ll have to follow the guidelines laid out here and here.

No comments:

Post a Comment