Permalink
Browse files

add example

  • Loading branch information...
1 parent 51665ea commit 340ba3479c729dffccfe06ecd2380119a041115f vol4ok committed Jul 23, 2012
Showing with 49 additions and 2 deletions.
  1. +22 −0 example/app.coffee
  2. +2 −0 example/server.js
  3. +1 −0 example/views/head.html
  4. +3 −0 example/views/index.html
  5. +14 −0 example/views/layout.html
  6. +1 −0 example/views/temp.html
  7. +6 −2 package.json
View
@@ -0,0 +1,22 @@
+express = require 'express'
+
+app = express()
+
+app.set('view engine', 'html')
+app.set('layout', 'layout')
+app.set('partials', head: "head")
+
+#app.enable('view cache')
+
+app.engine 'html', require('../hogan-express.coffee')
+app.set('views', __dirname + '/views')
+
+app.use(express.bodyParser())
+app.use(app.router)
+
+app.get '/', (req,res)->
+ res.locals = what: 'World'
+ res.render "index", partials: {temp: 'temp'}
+
+
+app.listen(3000)
View
@@ -0,0 +1,2 @@
+require('coffee-script');
+require('./app.coffee');
View
@@ -0,0 +1 @@
+<h1>Test</h1>
View
@@ -0,0 +1,3 @@
+Hello {{what}}!
+
+{{> temp}}
View
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Test</title>
+</head>
+<body>
+
+ {{> head}}
+ <p>------------</p>
+ {{{ yield }}}
+
+</body>
+</html>
View
@@ -0,0 +1 @@
+<p>ololololoo</p>
View
@@ -1,8 +1,8 @@
{
"name": "hogan-express",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "Mustache template engine for express 3.x. Support partials and layout",
- "main": "index.js",
+ "main": "hogan-express.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -22,5 +22,9 @@
"license": "MIT",
"dependencies": {
"hogan.js": ">=2.0.0"
+ },
+ "devDependencies": {
+ "coffee-script": "1.x.x",
+ "colors": "0.6.x"
}
}

0 comments on commit 340ba34

Please sign in to comment.