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

Check for existence of base templates does not work for development mode #68

Closed tormozz48 closed 9 years ago

tormozz48 commented 9 years ago

Hello.

Now I'm working on task https://github.com/enb-bem/enb-bemxjst/issues/60. I have used this way for check the existence of base templates.

oninit(function(exports, context) {
  if(!context.BEMContext) throw Error('Seems like you have no base templates from i-bem.bemhtml');
})

But it seems that this works only for production mode. I need to have this validation for development mode too.

Please help for resolve this issue.

@blond @tadatuta @veged

veged commented 9 years ago

there is a error catching for everything — https://github.com/veged/xjst/blob/3a2fe343c9856fe4a163bd3d07b194350c41211b/lib/xjst/compiler/base.js#L109

we need to add some filter so our particular errors can be thrown up — since it was introduce for proper work of match(this.my.custom.match) we can add some check like e instanceof TypeError

i.e.

           '} catch (e) {\n' +
           '  // Ignore only TypeError errors\n' +
           '  if(!(e instanceof TypeError)) throw e;' 
           '}\n' +

@tormozz48 do you wanna make PR? ;-)

tormozz48 commented 9 years ago

I have tested enb-bemxjst package with forked bem-xjst and xjst dependencies which contains fix from above. It seems that all is OK.

@blond @tadatuta @veged

We need to: