Skip to content

Instantly share code, notes, and snippets.

@nolim1t
Created May 11, 2012 05:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nolim1t/2657677 to your computer and use it in GitHub Desktop.
Save nolim1t/2657677 to your computer and use it in GitHub Desktop.
Sample Templating with express and jade
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
!!! 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
# 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