How to use closure template in JavaScript ? (Wrong documentation and examples...!!)

82 views
Skip to first unread message

Raphaël COMBEAU

unread,
Jun 18, 2017, 11:24:24 AM6/18/17
to Closure Templates Discuss
Hi,

Anyone can help me to understand how to use the soyutils_usegoog.js because soyutils.js has been removed from closure template by google team and the developpers site is not up-to-date because it is mention to use soyutils.js .....

As I can read on the developpers site, we must use closure library but they are no explanations about which files we have to use..

Many thanks to all of us for the help you can provide me.

Best regards.

gramic

unread,
Jun 19, 2017, 3:56:17 AM6/19/17
to Closure Templates Discuss
You should use the whole closure library and then include soyutils_usegoog.js from the sources of closure templates + your own source files.
Closure templates were trying to be a separete independant library, that's why they "copy" a lot of Closure Library. The duplication grew larger and they decided to have dependancy on Closure libary.
So now, instead of using soy.renderAsElement from closuretemplatesSoyUtils.js file, they are using soy.renderAsElement from soyutils_usegoog.js inside the template library sources.

Probably you are not familiar how compilers work, so in a vary simple way I would try to explain it.
If you have two separate files with the same function name but different implemantation functionA_v1.js and functionA_v2.js

When my source file uses functionA() it doesn't care from which file that function comes. So you just include in the compiler command line the file that you want.

I don't know what you are using to build your projects but I would suggest https://github.com/bazelbuild/rules_closure for easy and painful way to build.
Reply all
Reply to author
Forward
0 new messages