I would like to share templates between the client and server, and I was hoping to get advice on the right approach. Here are some details about my situation:
- We do not use Closure Library, but we do use Closure Compiler via Plovr (SIMPLE_OPTIMIZATIONS).
I got something simple to work using plovr after switching the top level of our soy namespace to soy.* from company.*. Otherwise plovr returns "ERROR - Variable company first declared in ... prod-externs.js". The main remaining issue is i18n.
## Variation #1 - Add Closure
## Variation #2 - No Closure
I used the experimental-exclude-closure-library option and explicitly list the transitive set of soy templates to include in the plovr config. This is similar to our current JS situation (not great I know), but it does not appear this mode allows for i18n message lookup. Ideally I would like to wrap messages in a JS call "company.msg('message text')" which can access a lookup map that we ship with the page. I suspect that is a hard change to make, deep in Soy JsSrc compiler though.
I'm leaning towards the "Add Closure" variation since the i18n problem seems easier to resolve, and maybe that can be the start of using goog.require / goog.provide more broadly.
Anyone have thoughts on the approach or other ideas?