2

I'm trying use eco for client-side templating. I have multiple .eco templates that I'd like to combine into one js file - I know I can just combine the js files after they are generated but that's a lot of repeated boilerplate. Is there a better way to do this?

Naren
  • 1,910
  • 1
  • 17
  • 22

2 Answers2

3

Look into stitch by Sam Stephenson (author of eco). It bundles your javascript, coffeescript and eco templates into a single file, and gives you a simple require on the client side. It compiles your eco templates to functions, so they're really fast on the client.

Linus Thiel
  • 38,647
  • 9
  • 109
  • 104
  • 1
    I looked at stitch, but it seems like all it is doing is taking the output of the different compiled .eco files and concatenating them. If I look at the source of a generated "stitched" file, it still has multiple "__sanitize" functions defined, one for each template. Ideally this could be optimized into abstracting out the common boilerplate across all templates as much as possible. Does this behavior sound par for the course for stitch or am I doing it wrong? – Naren Mar 09 '12 at 21:43
  • It's true that there is some code duplication, and I agree that it would be cool to see it handled in stitch. You might want to try running it through the closure compiler or uglify. – Linus Thiel Mar 09 '12 at 21:59
0

I have the same issue and so far the only alternative I see is to use Milk (mustache in coffeescript) and call the library from the browser.

Radek
  • 3,913
  • 3
  • 42
  • 37