Gracefully upgrading a component to use block params?


#1

I’m trying to wrap my head around the best approach to gracefully deprecate and then require the use of block params on a component.

I have a component that was developed some time ago, and is in wide use in my app as well as others. It uses “magic” to introduce a variable to the template, because that is the tool I had at the time:

{{#nf-x-axis}}
  <text>{{tick.value}}</text>
{{/nf-x-axis}}

I want to move to using block params, and @lightblade graciously contributed a PR to do just that… now it can be used as follows:

{{#nf-x-axis as |tick|}}
  <text>{{tick.value}}</text>
{{/nf-x-axis}}

The problem is this breaks the original usage of the component. Meaning the former example will now render nothing.

I’m looking for a way to introduce the new feature, but add a deprecation warning to “old usage” cases.

There is additional discussion here: https://github.com/Netflix/ember-nf-graph/pull/31

Any help or suggestions are greatly appreciated.


#2

…AAAANNDDD… while I was typing that the brilliant @jayphelps came up with a solution.