Skip to content

Commit

Permalink
runtime: applyNext({ changes })
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 27, 2015
1 parent 321b135 commit 3f9e352
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ BEMHTML.prototype.compile = function compile(templates) {
var out = tree.build(templates, [
localWrap,
applyCtxWrap,
function applyNextWrap() { return self.applyNext(); },
function applyNextWrap(changes) {
if (changes)
return self.local(changes, applyNextWrap);
return self.applyNext();
},
apply
]);

Expand Down
11 changes: 11 additions & 0 deletions test/runtime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ describe('BEMHTML compiler/Runtime', function() {
}, { block: 'b1', content: 'ohai' }, '<div class="b1">{%ohai%}</div>');
});

it('should support applyNext({ ... })', function() {
test(function() {
block('b1').content()(function() {
return '%' + this.wtf + applyNext() + '%';
});
block('b1').content()(function() {
return '{' + applyNext({ wtf: 'no ' }) + '}';
});
}, { block: 'b1', content: 'ohai' }, '<div class="b1">{%no ohai%}</div>');
});

it('should support local', function() {
test(function() {
block('b1').content()(function() {
Expand Down

0 comments on commit 3f9e352

Please sign in to comment.