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

default mode inconsistency between versions #74

Closed tadatuta closed 9 years ago

tadatuta commented 9 years ago

For BEMJSON { block: 'b1' } and

block('b1').def()(function() {
    // returns undefined
});

with bem-xjst 1.x results in an empty string and with bem-xjst 2.x in 'undefined'.

That's not a big issue but if it's easy to fix on bem-xjst side I think it'd be convenient.

// cc @indutny @veged

indutny commented 9 years ago

@tadatuta def() mode is required to return string now. It works in completely different way internally, and there was no such requirement in 1.x version.

See: https://github.com/bem/bem-xjst/wiki/Notable-changes-between-bem-xjst@1.x-and-bem-xjst@2.x for more info.

tadatuta commented 9 years ago

@indutny will additional check for undefined to return empty sting for such case do any harm?

indutny commented 9 years ago

@tadatuta it might.

block('b1').def()(function() {
  applyNext();
});

Will return empty string instead of applyNext() result. I think it is probably better to require users to return string value. This way we will be sure that everyone has caught up to our changes.

tadatuta commented 9 years ago

Sounds reasonable, thanks!

qfox commented 8 years ago

Guess, it could and should be linted. Can't agree that this decision was right.