tag:blogger.com,1999:blog-8145593511362203982.post3377813602148606937..comments2015-03-12T05:55:06.623-05:00Comments on PhilCali Code v0.1: Who needs a Template Engine?Philiphttp://www.blogger.com/profile/06896443671786220765noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8145593511362203982.post-23251211798441320122011-01-29T11:11:14.769-06:002011-01-29T11:11:14.769-06:00Ha! A very interesting idea, Brad!
There's a...Ha! A very interesting idea, Brad! <br /><br />There's a way to achieve this by doing a small amount of legwork with the remote control library in the last post.<br /><br />Basically, you could have a TemplateFactory singleton object that allows for a custom signals to be sent, something like register template or something. It could also do preregistration of known templates on server start up. <br /><br />The template designer could write a template to be registered, and simply compile and run from the sbt command line to see changes. (I envision templates for an app to be a child project of the web app. This way, when a designer makes a new template or changes an existing one, packaging and publishing the jar would allow the server to pick up the changes on start up.)<br /><br />This approach could still give template designers access to request and session variables that would be passed in the context of the template which is passed to the template factory.<br /><br />The servlet will always request a template from the template factory who may contain real-time changes from the template designer's template.<br /><br />Unfortunately, neither of our solutions would work on appengine, where this particular web app will live.Philiphttps://www.blogger.com/profile/06896443671786220765noreply@blogger.comtag:blogger.com,1999:blog-8145593511362203982.post-92026398187659040682011-01-24T19:59:11.443-06:002011-01-24T19:59:11.443-06:00whoa, thanks for the props! And I must admit, it&#...whoa, thanks for the props! And I must admit, it's pretty cool to get compile time type safety.<br /><br />So, here's another crazy idea. If you were working with a designer, could these template classes be run as a Scala script? Your Scala server could invoke the actual Scala executable from the command line, pass it the name of the template to invoke, the template's main (defined in a common super class?) is invoked and returns HTML that the original Scala server displays.<br /><br />This would only be useful in development, but, if it worked, the server wouldn't have to be restarted for template changes!<br /><br />I have no idea how you'd pass the request and session variables though. Maybe those should be some type of proxy back to the original server. Ok, this is getting out of hand.Brad Cupithttps://www.blogger.com/profile/16921472988885989302noreply@blogger.com