sbmaxx / bem-priv

Use the power of inherit.js to generate BEMJSON with BEMPRIV blocks
21 stars 6 forks source link

Can't return empty value without overloading #bemjson method #18

Closed ignovak closed 9 years ago

ignovak commented 9 years ago

Now, if I need to return empty value instead of block in some cases, I have to write some redundant code:

// old implementation using "blocks"
blocks['my-block'] = function(data) {
  if (!data.myData) return '';
  return { blocks: 'my-block', content: data.myData };
}

// "bempriv" implementation
BEMPRIV.decl('my-block', {
  init: function() {
    if (!this.data.myData) return;
    this.content(this.data.myData);
  },
  bemjson: function() {
    if (this.data.myData) {
      return this.__base();
    }
  }
}

Probably, it worth to implement some way to reach that without overloading bemjson method.

sbmaxx commented 9 years ago

@ignovak take a look https://github.com/sbmaxx/bem-priv/pull/19