How can I passa viewModel or Scope property into a stache helper?

I have a stache helper in scope on a template that swaps out views when called on a can-click listener. The click binding looks like this:

<li can-click="switchView 'listView'"></li>

How can I pass a viewModel or scope property into the helper? The only arguments that seem to get passed into the helper as parameters are strings. I’d like to do this to send along any relevant data for the next view.

I’d like to do this:

<li can-click="switchView 'listView' ."></li>

But when I do, I get this:

switchView: function (viewName, obj) {
    console.log(arguments);
    // ['listView']
},

Any ideas? I must be misunderstanding something.

Thanks,
Alex

Hi Alex,

I don’t know if you’ve managed to get sorted but have you taken a look at this:

https://canjs.com/docs/can.stache.key.html

Seems as though %viewModel may do the trick. Also, the binding syntax (https://canjs.com/docs/can.view.bindings.html) has been changed somewhat but I guess that would depend on your version of canjs.

Eben