将 soyutils 与 Google Closure 结合使用的正确方法是什么?
我正在尝试将 Google Closure 模板 (Soy) 与 Google 关闭。
我按照指示添加了 soyutils_usegoog.js
实用程序文件。该文件提供了生成的模板使用的许多实用程序,特别是 soy.StringBuilder
。下面是它的创建方式:
soy.StringBuilder = goog.string.StringBuffer;
soyutils 文件需要上面几行 goog.string.StringBuffer
,但是当在非编译模式下运行时,这会导致运行时错误,因为 StringBuffer
所在的位置在 soyutils 执行之后之后才会被加载。
除非我弄错了,否则 Closure 中的 JS 文件不应立即访问它们“需要”的名称空间。 标签仅在当前脚本执行后(非编译模式)添加,因此立即使用将导致运行时错误。
简而言之,如何加载 soyutils_usegoog.js
而不会由于 good.string.StringBuffer
的早期访问而触发运行时错误。
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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用已编译的模板作为输入(以及
soyutils_usegoog.js
)重新创建 deps.js?然后您是否使用了goog.require
模板?像这样的东西应该有效:Are you recreating deps.js with your compiled templates as an input (and
soyutils_usegoog.js
)? And then are yougoog.require
-ing your template? Something like this should work:也许这个问题已在 http://groups.google.com/group/closure- 上提出过模板讨论?
Perhaps the question has been asked on http://groups.google.com/group/closure-templates-discuss?