I am trying to use Google Closure templates (Soy) with Google Closure.
I am including the soyutils_usegoog.js
utilities file as instructed. This file provides a number of utilities used by the generated templates, notably soy.StringBuilder
. Here's how it is creating it:
soy.StringBuilder = goog.string.StringBuffer;
The soyutils file requires goog.string.StringBuffer
a few lines above, but when running in non-compiled mode this results in a runtime error because the JS file that StringBuffer
resides in will not be loaded until after soyutils has executed.
Unless I am mistaken, JS files in Closure should not immediately access namespaces that they 'require'. The <script>
tag is only added after the execution of the current script (in non-compiled mode) so immediate usage will result in a runtime error.
In short, how can I load in soyutils_usegoog.js
without triggering a runtime error due to the early access of good.string.StringBuffer
.