Skip to content

Instantly share code, notes, and snippets.

@battlejj
Created July 22, 2013 13:58
Show Gist options
  • Save battlejj/6054030 to your computer and use it in GitHub Desktop.
Save battlejj/6054030 to your computer and use it in GitHub Desktop.
fs = require 'fs'
hogan = require 'hogan.js'
routes = {}
templates = {}
templates =
layout: hogan.compile(fs.readFileSync('./views/layout.hjs').toString())
index: hogan.compile(fs.readFileSync('./views/index.hjs').toString())
routes.index = (req, res) ->
page =
title: 'Express'
someVar: 'test'
anArray: [{name:'item1'}, {name:'item2'}]
page.template = templates.index.render(page)
#console.log(page)
res.send(templates.layout.render(page))
module.exports = exports = routes
<h1>{{ title }}</h1>
<p>Welcome to {{ title }}</p>
{{ someVar }}
<ul>
{{# anArray }}
<li>{{ name }}</li>
{{/ anArray }}
</ul>
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
Hey
{{{ template }}}
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment