Created
May 11, 2012 05:19
-
-
Save nolim1t/2657677 to your computer and use it in GitHub Desktop.
Sample Templating with express and jade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h2 Hello World | |
h3 Hello World | |
:markdown | |
This is some **test** markdown text | |
we can even link to [stuff](http://google.com) | |
ul.list | |
- each i in data | |
li=i.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!! 5 | |
html | |
head | |
title= typeof(title) !== 'undefined' ? title : "Untitled template" | |
meta(name='keywords', content='foo bar baz') | |
meta(name='description', content='Description') | |
meta(name='og:title', content=typeof(title) !== 'undefined' ? title : "Untitled template") | |
link(rel='shortcut icon', href='/path/to/favicon.png', type='image/x-icon') | |
body | |
h1 #{typeof(title) !== 'undefined' ? title : "Untitled template"} | |
#main | |
!= body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# npm install express | |
# npm install jade | |
# npm install markdown-js | |
express = require 'express' | |
static = express.static __dirname + "/public" | |
bodyParser = express.static(__dirname + "/public") | |
favicon = express.favicon() | |
cookieParser = express.cookieParser() | |
app = express.createServer bodyParser, static, favicon, cookieParser | |
app.configure () -> | |
app.set 'view engine', 'jade' | |
app.set 'views', './views' | |
app.get '/', (req, res) -> | |
data = [{id: 1, name: "Item One"}, {id: 2, name: "Item Two"}] | |
res.render('home', {title: "This is a title", data: data}) | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment