mauricemach/coffeekup — Issue #105: How to access tag helpers from inside an object?
Author: viatropos
Created: 2012-01-11 04:33:42+00:00
State: open

If I do this:

``` coffeescript
helpers =
formFor: ->
form = new Form(arguments…)
form.render()

class Form
constructor: ->

render: ->
form action: "/", ->
input type: 'text'
```

…the `form` and `input` methods are undefined.

I see that it has something to do with how the function scopes are declared here:

- https://github.com/mauricemach/coffeekup/blob/master/src/coffeekup.coffee#L299

Since `this` and `global` don't include the coffeekup tag helper methods, how do I use them here?

I can see running them through the `coffeekup.compile` method like this:

``` coffeescript
class Form
render: ->
require('coffeekup)'.compile ->
form action: "/", ->
input type: 'text'
```

But that seems like overkill. Is there a way to fix/add this?

Thanks!