Skip to content

Commit c47dc45

Browse files
Added deep-extend test case to express server.
1 parent 99f60fb commit c47dc45

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

dist/handlebars-layouts.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function layouts(handlebars) {
114114
* @param {String} name
115115
* @param {Object} options
116116
* @param {Function(Object)} options.fn
117-
* @return {String} Block content.
117+
* @return {String} Modified block content.
118118
*/
119119
block: function (name, options) {
120120
options = options || {};
@@ -169,7 +169,6 @@ function layouts(handlebars) {
169169
*/
170170
layouts.register = layouts;
171171

172-
// Legacy
173172
module.exports = layouts;
174173

175174
},{}]},{},[1])(1)

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function layouts(handlebars) {
113113
* @param {String} name
114114
* @param {Object} options
115115
* @param {Function(Object)} options.fn
116-
* @return {String} Block content.
116+
* @return {String} Modified block content.
117117
*/
118118
block: function (name, options) {
119119
options = options || {};
@@ -168,5 +168,4 @@ function layouts(handlebars) {
168168
*/
169169
layouts.register = layouts;
170170

171-
// Legacy
172171
module.exports = layouts;

test/expected/deep-extend.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!doctype html>
2+
<html lang="en-us">
3+
<head>
4+
<title>Users</title>
5+
6+
<link rel="stylesheet" href="assets/css/screen.css" />
7+
</head>
8+
<body>
9+
<div class="site">
10+
<div class="site-hd" role="banner">
11+
<h1>Users</h1>
12+
<h2>Goodnight Moon</h2>
13+
14+
</div>
15+
16+
<div class="site-bd" role="main">
17+
<div class="grid">
18+
<div class="col 2of3">
19+
<p>Dolor sit amet.</p>
20+
<p>Lorem ipsum.</p>
21+
</div>
22+
23+
<div class="col 1of3">
24+
<p>Consectetur adipiscing elit.</p>
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div class="site-ft" role="contentinfo">
30+
<small>&copy; 1984</small>
31+
<p>MIT License</p>
32+
</div>
33+
</div>
34+
35+
<script src="assets/js/controllers/home.js"></script>
36+
</body>
37+
</html>

test/express.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ utils.registerPartials(partials);
1717
// Server
1818
express()
1919
// Settings
20-
.set('view engine', 'hbs')
2120
.set('views', views)
21+
.set('view engine', 'html')
22+
.engine('html', require('hbs').__express)
2223

2324
// Routes
24-
.get('/append', function (req, res) { res.render('append', data); })
25-
.get('/embed', function (req, res) { res.render('embed', data); })
26-
.get('/extend', function (req, res) { res.render('extend', data); })
27-
.get('/prepend', function (req, res) { res.render('prepend', data); })
28-
.get('/replace', function (req, res) { res.render('replace', data); })
25+
.get('/append', function (req, res) { res.render('append', data); })
26+
.get('/bogus', function (req, res) { res.render('bogus', data); })
27+
.get('/deep-extend', function (req, res) { res.render('deep-extend', data); })
28+
.get('/embed', function (req, res) { res.render('embed', data); })
29+
.get('/prepend', function (req, res) { res.render('prepend', data); })
30+
.get('/replace', function (req, res) { res.render('replace', data); })
2931

3032
// Start
3133
.listen(3000);

test/fixtures/deep-extend.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{#extend "layout2col"}}
2+
{{#content "subtitle" mode="append"}}
3+
<h2>Goodnight Moon</h2>
4+
{{/content}}
5+
6+
{{#content "left" mode="prepend"}}
7+
<p>Dolor sit amet.</p>
8+
{{/content}}
9+
10+
{{#content "right"}}
11+
<p>Consectetur adipiscing elit.</p>
12+
{{/content}}
13+
14+
{{#content "footer" mode="append"}}
15+
<p>MIT License</p>
16+
{{/content}}
17+
{{/extend}}

0 commit comments

Comments
 (0)