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

generate method is broken #461

Closed qfox closed 7 years ago

qfox commented 7 years ago

In v7:

$ npm i bem-xjst@7
bem-xjst@7.7.4 node_modules/bem-xjst
$ node -p "require('bem-xjst').bemhtml.generate()" > out-v7.js
$ node -p "require('./out-v7.js').apply({block:'qwe'});"
<div class="qwe"></div>

In v8:

$ npm i bem-xjst@8
bem-xjst@8.6.11 node_modules/bem-xjst
node -p "require('bem-xjst').bemhtml.generate()" > out-v8.js
[eval]:1
require('./out-v8.js').apply({block:'qwe'});

But at the same time:

$ node -p "require('./out-v8.js'); global.bemhtml.apply({block:'qwe'});"
<div class="qwe"></div>

Perhaps it should not work like this and put bemhtml variable into the global.

I've made a PR for testing CJS: https://github.com/bem/bem-xjst/pull/457

miripiruni commented 7 years ago

Fixed in https://github.com/bem/bem-xjst/pull/457