-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
86 lines (72 loc) · 1.9 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var express = require('express');
var app = express();
// If are trying to use this example, replace the line below to
//var renderer = require('hogan-cached');
var renderer = require('../index.js');
app.engine('html', renderer.__express);
app.set('view engine', 'html');
app.set('views', './test/views');
// Global Partials: They can be used anywhere
app.set('partials', {
// Lets define "footer" as a global partial
'footer': 'partials/footer'
});
app.get('/', function(req, res) {
res.render('index', {
title: 'All Test',
tests: [
{name: 'Basic', url: 'basic'},
{name: 'List', url: 'list'},
{name: 'Lambda', url: 'lambda'},
{name: 'Partials', url: 'partials'},
{name: 'ClearCache', url: 'clearcache'}
]
});
});
app.get('/basic', function(req, res) {
res.render('basic', {
title: 'Basic Test',
description: 'Hello there!',
year: 2016
});
});
app.get('/list', function(req, res) {
res.render('list', {
title: 'List Test',
names: [
{name: 'test'},
{name: 'test2'}
]
});
});
app.get('/lambda', function(req, res) {
res.render('lambda', {
title: 'Lambda Test',
name: 'World',
center: function() {
return function(text) {
return '<div style="text-align: center;">' + text + '</div>';
};
},
logged_in: false
});
});
app.get('/partials', function(req, res) {
res.render('partials', {
title: 'Partial Test',
name: 'World',
year: 2016,
partials: {
'text': 'partials/text'
}
});
});
app.get('/clearcache', function(req, res) {
renderer.clearCache();
res.render('basic', {
'title': 'Cache',
'description': 'The cache was cleared',
'year': 2016
});
});
app.listen(8081);