Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Created June 10, 2014 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanepiper/43f7479701492e841f40 to your computer and use it in GitHub Desktop.
Save tanepiper/43f7479701492e841f40 to your computer and use it in GitHub Desktop.
<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>
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