just make a custom slug.js file and load hem
Just checking but have you required it in your scripts?
Im not entirely sure how it works specifically but yes. Also in setup.coffee :-)
require('haml/lib/haml')
You can't require a view unless its inside a module.
You'd have to wrap the output of your template and place a modules.export call expoting the templates out put from my understanding.
If I could have a link to a URL repository I could give you a more detailed example.
I think from memory the build of hem compiles templates at run time.
Yes, but by default they are sandboxed. As I said if you have a report URL I can help you more.
Sorry I mean repository
Felix, I don't know if you understand much of this but basically hem creates the ability to precompile eco files when you require files. To do what your doing, you would have to fork hem's repository and add your own code to ./src/compilers.coffee and compile your own custom version of hem.
I found it easier to create a template master class which dealt with adding vars and rendering templates. That meant that the views became classes which extended the template class.
That means I could do this theoretically in the controller:
@html require('views/home').render data
The home template file would look like this:
Template = require('helpers/Template')
class home:
@extends Template
constructor:
super
#overide existing template var
@template = '''
%h1
'''
#overide existing data var with default data related to template
@data:
h1: "Hello World"
So the function to render the template with the data would already be defined in helpers/Template.coffee
Hope that helps you out :-)
- Daniel J Holmes
www.djcentric.com
I noticed you haven't compiled hem into a bin format. Are you loading hem using its executable or using "node ./node_modules/hem/lib/hem.js server"?
Also I am not entirely sure why you are parsing your templates in coffeescript?
Alex does that exec run the compiled js files under lib? Or do you need to recompile the exec?
Depending on how it works you'd probably have to replace the executable on your system and replace your global copies of the hem scripts as well.
This means that running npm might override your changes.