Reputation: 16435
I'm using the Google Closure Compiler in advanced mode for a project I'm working on. This is an extremely aggressive JavaScript compiler that can optimize your code quite a bit. However, in order to do this it needs to see the whole picture. That is to say, if I assign something to window.foo, and then only access window.foo from JS that the compiler can't see, it won't exist, since it will have been changed to window.f or even removed all together.
This complicates things when it comes time for JS temples. Since they are loaded at runtime out of a string, they tend to refer to variables that no longer exist. This can be mitigated slightly by using quoted assignment for the object used to provide values to the template. eg. templateContext['user'] rather then templateContext.user. However, that doesn't allow me to do templateContext.user.username and so on, so it's somewhat limiting.
tl;dr: I need a JavaScript templating solution that can be pre-processed into pure JavaScript that I can include in a .js file.
Does anything like this exist?
Upvotes: 2
Views: 629
Reputation: 14605
You can try Dojo 1.6. There is a way to make it work quite seamlessly with Closure in Advanced mode, even with Dijit templates.
Upvotes: 0
Reputation: 16435
Honestly, I'm not sure how I missed this: Google Closure Templates.
Upvotes: 1