Closed TylerLH closed 12 years ago
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.
I'm closing this for now, if your still having problems feel free to re-open.
Thanks for the notes:)
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 }}.