netzpirat/haml-coffee

HamlCoffee does not fully work with express-partials

denysonique opened this issue · 7 comments

When using HamlCoffee on the server side with Express and trying to call:

!= partial 'foobar'

it results in

ReferenceError: partial is not defined

express-partial layout functionality works fine.

That was my mistake of not using @partial
But when trying to use it the correct way it still won't work:

app = require('express')()
partials = require('express-partials)

app.engine 'hamlc', require('haml-coffee').__express
app.set 'view engine', 'hamlc'
app.use partials()

View:

!= @partial 'path/to/view'

Error:

 Error: Cannot find module 'hamlc'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
...

This is the temporary workaround I am using at the moment

hamlc = require('haml-coffee').__express

partials.register '.hamlc', (src, opts)->
  hamlc opts.filename, (err, result)->
    return result

hamlc = require('haml-coffee').__express

partials.register '.hamlc', (src, opts)->
  hamlc opts.filename, opts, (err, result)->
    throw err if err
    return result

with locals support

Interesting, thanks for sharing your finding. Does this mean express-partials needs to add explicit support for haml-coffee or should we just add this to the README?

Closing this since lack of response.

I just ran into this same error. It would be nice if the README section on partials included the code to register hamlc.

Feel free to open a pull request :)