5

Has anyone figured out a good solution for shared templates? I don't want to duplicate HTML between client and server. Mustache would be good except for its lack of i18n support (Twitter's contrib is js only). EJS would be perfect if its syntax was directly compatible with ERB, but not quite.

Ideally templates would live in app/views/controller/action.html.erb (or whatever templating lang) and a templates.js.erb manifest could bundle those templates up. Having a compatible syntax for a serverside render and clientside render is key to avoiding duplication.

devth
  • 2,738
  • 4
  • 31
  • 51

1 Answers1

1

With this pull request haml-js is gaining client-side support which makes it a nice candidate for solving my issue. I will investigate further and see if it meets my needs.

devth
  • 2,738
  • 4
  • 31
  • 51
  • Turns out to be a little awkward since the JS implementation is not fully compatible with the ruby (sort of defeating the whole purpose). Still searching...current idea is to render EJS serverside with ExecJS. – devth Jul 21 '11 at 22:49
  • Did you find a proper solution yet? – Julian Maicher Oct 07 '11 at 09:40
  • Not really. Mustache is still the best bet, and now there's a JST compiler for Mustache. I haven't been working on solving this problem lately though. – devth Oct 07 '11 at 18:06