Created
June 10, 2014 19:23
-
-
Save tanepiper/43f7479701492e841f40 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<title><%= title %></title> | |
</head> | |
<body> | |
<div class="blog"> | |
<h1><%= title%></h1> | |
<% blogItems.forEach(function(item) { %> | |
<div class="item"> | |
<h3><%= item.title %></h3> | |
<div> | |
<%= item.text %> | |
</div> | |
</div> | |
<% }) %> | |
</body> | |
</html> |
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
var Ejs = require('ejs'); | |
var Hapi = require('hapi'); | |
var Instance = {}; | |
var Labels = []; | |
Instance.data = { | |
title: 'This Blog', | |
blogItems: [{ | |
title: 'Blog Item 1', | |
text: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' | |
}, { | |
title: 'Blog Item 2', | |
text: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' | |
}, { | |
title: 'Blog Item 3', | |
text: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' | |
}, { | |
title: 'Blog Item 4', | |
text: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' | |
}, { | |
title: 'Blog Item 5', | |
text: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...' | |
}] | |
}; | |
Ejs.registerHelper = function (name, fn) { | |
Ejs.filters[name] = fn; | |
}; | |
var server = Instance._server = Hapi.createServer('localhost', 8000, { | |
app: Instance, | |
files: { | |
relativeTo: __dirname + '/public', | |
}, | |
labels: Labels, | |
views: { | |
engines: { | |
html: 'ejs' | |
}, | |
path: __dirname + '/views' | |
} | |
}); | |
server.route({ | |
method: 'GET', | |
path: '/', | |
handler: function (request, reply) { | |
reply.view('blog', Instance.data); | |
} | |
}); | |
server.start(function () { | |
console.log('Server started at: ' + server.info.uri); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment