You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you define helper methods in your view class they are available in ruby, but they aren't automatically available in JavaScript. I'm not sure there is anyway to do this automatically.
In your javascript you could create your own view presenter object to pass to the template, something like this:
var userListView = {
foo: 'bar'
}
var users = poirot.userList(userListView)
This presenter object could be more dynamic if you need to pass a list of users to your user list view:
var userListViewPresenter = function (user) {
return {
fullName: [user.firstName, user.lastName].join(' ')
}
}
var users = poirot.userList({
users: users.map(userListViewPresenter)
})
Finally you could also define an as_json method on your ruby view class, and then expose this to your JavaScript layer.
Hopefully my last issue. Any help would be greatly appreciated.
I'm trying to access my helper methods in my optional view class. For example:
When loading the template with data, anything I define inside the JS obviously makes it into the view except for {{ foo }}.
The text was updated successfully, but these errors were encountered: