ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

Clash of helpers and references #228

Closed arggh closed 8 years ago

arggh commented 8 years ago

I've been wondering about weird problems for a couple of times, where the culprit has turned out to be a name clash between a helper and a reference-binding in ViewModel.

For example:

<template name="items>
   {{#each items}}
      {{>itemEl item=this}}
   {{/each}}
</template>

<template name="itemEl">
  <div {{b "ref: item"}}>
     {{itemProp}}
  </div>
</template>

For the sake of developer experience, it would be nice to get a warning in such a situation.

ManuelDeLeon commented 8 years ago

I "kinda" fixed it. I added an error message if the view model exists. There's nothing I can do if the view model for itemEl is implicit. In your case, for you to get the warning, you would have to explicitly define a view model, even if it's an empty one:

Template.itemEl.viewmodel({
})

It isn't ideal but it's better than nothing. Pick up v4.0.13