Skip to content

Commit

Permalink
Corrected content rendering order.
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonmoeller committed Apr 25, 2015
1 parent 7ddfe02 commit 8632843
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/handlebars-layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function applyStack(context) {
var stack = getStack(context);

while (stack.length) {
stack.pop()(context);
stack.shift()(context);
}
}

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function applyStack(context) {
var stack = getStack(context);

while (stack.length) {
stack.pop()(context);
stack.shift()(context);
}
}

Expand Down
26 changes: 26 additions & 0 deletions test/expected/templates/deep-extend.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype>
<html>
<body>
<p>d1.1</p>
<p>d1</p>
<p>c1.1</p>
<p>c1</p>
<p>b1.1</p>
<p>b1</p>
<p>a1</p>

<p>d2</p>

<p>a3</p>
<p>b3</p>

<p>c4</p>
<p>d4</p>

<p>c3</p>

<p>d5</p>

<p>d3</p>
</body>
</html>
4 changes: 4 additions & 0 deletions test/fixtures/partials/deep-b.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<p>b1</p>
{{/content}}

{{#content "top" mode="prepend"}}
<p>b1.1</p>
{{/content}}

{{#content "middle"}}
<p>b2</p>
{{/content}}
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/partials/deep-c.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<p>c1</p>
{{/content}}

{{#content "top" mode="prepend"}}
<p>c1.1</p>
{{/content}}

{{#content "middle"}}
<p>c2</p>
{{/content}}
Expand All @@ -13,7 +17,7 @@
{{{block "c"}}}
{{/content}}

{{#content "b" mode="prepend"}}
{{#content "b" mode="append"}}
<p>c4</p>
{{/content}}
{{/extend}}
25 changes: 25 additions & 0 deletions test/fixtures/templates/deep-extend.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{#extend "deep-c"}}
{{#content "top" mode="prepend"}}
<p>d1</p>
{{/content}}

{{#content "top" mode="prepend"}}
<p>d1.1</p>
{{/content}}

{{#content "middle"}}
<p>d2</p>
{{/content}}

{{#content "bottom" mode="append"}}
<p>d3</p>
{{/content}}

{{#content "b" mode="append"}}
<p>d4</p>
{{/content}}

{{#content "c" mode="append"}}
<p>d5</p>
{{/content}}
{{/extend}}
11 changes: 10 additions & 1 deletion test/handlebars-layouts.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ var handlebars,
config = {
partials: __dirname + '/fixtures/partials/',
fixtures: __dirname + '/fixtures/templates/',
expected: __dirname + '/expected/templates/'
expected: __dirname + '/expected/templates/',
actual: __dirname + '/actual/templates/'
};

describe('handlebars-layouts e2e', function () {
Expand Down Expand Up @@ -46,6 +47,7 @@ describe('handlebars-layouts e2e', function () {
vinylFs
.src(fixture)
.pipe(through.obj(compileFile))
// .pipe(vinylFs.dest(config.actual))
.on('data', expectFile)
.on('error', expectError);
}
Expand All @@ -64,6 +66,9 @@ describe('handlebars-layouts e2e', function () {

// Register partials
handlebars.registerPartial({
'deep-a': read(config.partials + '/deep-a.hbs'),
'deep-b': read(config.partials + '/deep-b.hbs'),
'deep-c': read(config.partials + '/deep-c.hbs'),
layout: read(config.partials + '/layout.hbs'),
layout2col: read(config.partials + '/layout2col.hbs'),
media: read(config.partials + '/media.hbs'),
Expand All @@ -77,6 +82,10 @@ describe('handlebars-layouts e2e', function () {
testWithFile('extend.html', data, done);
});

it('should deeply extend layouts', function (done) {
testWithFile('deep-extend.html', {}, done);
});

it('should embed layouts', function (done) {
var data = require('./fixtures/data/users.json');

Expand Down

0 comments on commit 8632843

Please sign in to comment.