bem / bem-xjst

bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server
https://bem.github.io/bem-xjst
Other
116 stars 48 forks source link

appendContent/prependContent escapes html #422

Closed golyshevd closed 7 years ago

golyshevd commented 7 years ago

bemjson

{
    block: 'foo'
}

bemhtml

block('foo')(
    prependContent()(() => ({
        elem: 'x', 
        content: 'before'
    })),
    appendContent()(() => ({
        elem: 'x', 
        content: 'after'
    }))
);

result

<div class="foo">&lt;div class="foo__x"&gt;before&lt;/div&gt;&lt;div class="foo__x"&gt;after&lt;/div&gt;</div>

Live example https://goo.gl/5wXovY


guess appendContent/prependContent is just sugar for content + applyNext, but this behaviour is unexpected

miripiruni commented 7 years ago

BTW, in this case you don’t need use arrow function at all.

block('foo')(
    prependContent()({
        elem: 'x', 
        content: 'before'
    }),
    appendContent()({
        elem: 'x', 
        content: 'after'
    })
);

I detect that bug exists only with arrow function…

qfox commented 7 years ago

Same with usual functions: https://goo.gl/82s0Hr

miripiruni commented 7 years ago

@zxqfox of course. And I fixed it already.