Templates soy

149 views
Skip to first unread message

markus

unread,
Sep 6, 2011, 2:15:00 PM9/6/11
to Closure Templates Discuss
Hello everyone,
i'm trying to use the closure library to program my new work...
I'm using soy templates to generate translation file for my
application.
It work fine until i try to import all inside my project.
I've a trouble to understand How i can use the files inside the
project.
It's possible to refer to generated js using goog.require instruction?


Thx,
Marco

Kai Huang

unread,
Sep 6, 2011, 2:42:35 PM9/6/11
to Closure Templates Discuss
I'm not sure I understand your question.

On Sep 6, 11:15 am, markus <gadaleta.ma...@gmail.com> wrote:
> Hello everyone,
> i'm trying to use the closure library to program my new work...
> I'm using soy templates  to generate translation file for my
> application.

Soy can only generate translation files for messages defined in Soy
templates. It cannot handle translation for your whole app.

> It work fine until i try to import all inside my project.
> I've a trouble to understand How i can use the files inside the
> project.
> It's possible to refer to generated js using goog.require instruction?

Yes, you can use goog.require on your template files' namespaces. What
you need to do is add the flag
--shouldProvideRequireSoyNamespaces
When this option is used, each generated JS file will contain a
goog.provide statement for the corresponding Soy file's namespace.

Sam Elkhateeb

unread,
Sep 6, 2011, 2:46:45 PM9/6/11
to closure-temp...@googlegroups.com
If I understood ur question right,
The closure templates compiler does it for you if you use the command line option
 --shouldProvideRequireSoyNamespaces  

this will add goog.provide to all your generated js files
then you can use goog.require in your js files

hope this helps

Marco Gadaleta

unread,
Sep 6, 2011, 5:18:26 PM9/6/11
to closure-temp...@googlegroups.com
ok, this is what i'm finding for..
but i've another trouble..

in the a.js generated by soy file i've this line
goog.provide('example.templates');
(it was generated after i've inserted  --shouldProvideRequireSoyNamespaces option)

So, what is the way to load it in main js file?

I've try with "goog.require('example.templates');"
but i've this error: "goog.require could not find: example.templates"

can you give me a hint about it?

Thx,
Marco
--
Marco

Sam Elkhateeb

unread,
Sep 6, 2011, 5:32:03 PM9/6/11
to closure-temp...@googlegroups.com
sounds like a dependency issue. The generated js file (a.js) needs to be added to the html page (using a script tag). However, Google Closure Library has a special way to do it: go over this document as a starting point

hope this gets you another step further
Sam
Reply all
Reply to author
Forward
0 new messages