TrevorBurnham/connect-assets — Issue #47: Template helpers don't work with CoffeeKup
Author: juriejan
Created: 2011-11-29 21:12:44+00:00
State: open

When using the css and js helpers in CoffeeKup, they only render if they are the last tag inside another tag.

CoffeeKup functions require them to write to a buffer. The return value of a function isn't always rendered.

I've had a look inside CoffeeKup but it doesn't seem to provide an easy way to attach new tags.

In the mean time the error can be bypassed by creating helpers that wrap the functions in a 'text' tag function (which basically just renders what you pass to it).

```coffeescript
ck = require 'coffeekup'

helpers = {
css: (attrs) ->
return text global.css(attrs)
js: (attrs) ->
return text global.js(attrs)
}

ck.render template, { hardcode: helpers }
```coffeescript

I'll keep an eye out to see if anything changes in coffee script that would allow us to easily attach these functions, but if anybody has already figured this out I'll be glad to help implement it.