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

Add to migration doc an example of element that forces flushing to stream #137

Closed qfox closed 8 years ago

qfox commented 8 years ago

Something like:

oninit(function(){
  BEMContext.prototype.flushieFlushie = function(){
    return _buf.splice(0).join('');
  };
  var _buf = [];
  BEMContext.prototype._flush = function(chunk){
    _buf.push(chunk);
    return '';
  };
});
// and
block('page').elem('flusher').def()(function(){ return this.flushieFlushie(); });

See: https://github.com/bem/bem-xjst/blob/678e33e19d2dc4289aee4f65ef80eeb393f7b4d9/test/runtime-test.js#L396-L434 https://github.com/bem/bem-xjst/wiki/Notable-changes-between-bem-xjst@1.x-and-bem-xjst@2.x#this_str-is-gone

blond commented 8 years ago

:+1:

miripiruni commented 8 years ago

https://github.com/bem/bem-xjst/wiki/Notable-changes-between-bem-xjst@1.x-and-bem-xjst@2.x#user-content-this_str-is-gone