Skip to content

Commit

Permalink
BEMTREE: special unescaped html field from BEMJSON should render as is
Browse files Browse the repository at this point in the history
  • Loading branch information
miripiruni committed Jan 9, 2017
1 parent b2ac50b commit 1dc8b03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/bemtree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ BEMTREE.prototype._run = function _run(context) {
if (!context || context === true) return context;
return BEMXJST.prototype._run.call(this, context);
};

BEMTREE.prototype.runUnescaped = function runUnescaped(context) {
this.context._listLength--;
return context;
};
4 changes: 2 additions & 2 deletions lib/bemxjst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ BEMXJST.prototype._run = function _run(context) {
typeof context.cls === 'undefined' &&
typeof context.attrs === 'undefined'
)
res = this.runUnescaped(context.html);
res = this.runUnescaped(context);
else if (utils.isSimple(context))
res = this.runSimple(context);
else
Expand Down Expand Up @@ -320,7 +320,7 @@ BEMXJST.prototype.runEmpty = function runEmpty() {

BEMXJST.prototype.runUnescaped = function runUnescaped(context) {
this.context._listLength--;
return '' + context;
return '' + context.html;
};

BEMXJST.prototype.runSimple = function runSimple(simple) {
Expand Down
9 changes: 9 additions & 0 deletions test/bemtree-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,13 @@ describe('BEMTREE engine tests', function() {
null, '', undefined, { block: 'b1' }, undefined, 0
]);
});

describe('Special html field', function() {
it('should render as is', function() {
test(function() {},
{ block: 'b1', content: { html: '<br>' } },
{ block: 'b1', content: { html: '<br>' } }
);
});
});
});

0 comments on commit 1dc8b03

Please sign in to comment.