2

So I'm using some server-side mustache templates with Scalatra and Scalate, and I'd like to use them in my Javascript code too.

Ideally I can load the same templates via some sort of ajax call, but I'm not really sure how to set that up with Scalatra + jetty.

Currently the templates live in

src/main/webapp/WEB-INF/templates/views/

This is the default for Scalatra, but those files aren't served statically by jetty, so I'm unsure how to share them with the front end.

Any suggestions?

Matthew Rathbone
  • 8,144
  • 7
  • 49
  • 79
  • You can make them statically available by putting them in a directory under webapp. If your jetty's context is "joe" and the webapp directory is "henry" then you should be able to get at a "something.mustache" with "joe/henry/something.mustache". Check out the "Serving static files" section [here](http://www.scalatra.org/2.2/getting-started/project-structure.html). – n0741337 Apr 16 '14 at 04:52
  • @n0741337 So presumably there's also some sort of configuration I can set with Scalate that tell it to look in that location for templates instead of WEB-INF? – Matthew Rathbone Apr 16 '14 at 14:27
  • `layoutTemplate` will allow that, but the mustache's compiled parent directory seems to still be under the control of Scalatra and didn't have the time to read their source. I ended up using relative paths for some ` – n0741337 Apr 16 '14 at 14:50
  • Ah! Got you, excellent, I'll play around with that function instead. – Matthew Rathbone Apr 16 '14 at 17:26

0 Answers0