Closure template question

654 views
Skip to first unread message

bradrice

unread,
Oct 15, 2010, 3:44:06 PM10/15/10
to Closure Templates Discuss
I'm trying the hello world example in Michael Bolin's "Closure, The
Definitive Guide" book. Very simple but I get exceptions when I run
it:

{namespace example.templates}

/**
* @param greeting
* @param year
*/

{template .welcome}
<h1 id="greeting">{$greeting}</h1>
The year is {$year}
{/template}


Exception in thread "main"
com.google.template.soy.base.SoySyntaxException: In file hello.soy,
template example.templates.welcome: Not all code is in Soy V2 syntax
(missing SoyDoc for template {template .welcome}).
at
com.google.template.soy.soytree.SoytreeUtils.createSoySyntaxExceptionWithMetaInfo(Unknown
Source)
...and about 20 more

how I call it on the command line:

java -jar ../closure-templates/build/SoyToJsSrcCompiler.jar --
outputPathFormat hello.soy.js --shouldGenerateJsdoc --
shouldProvideRequireSoyNamespaces hello.soy

Any ideas what is wrong?

Michael Bolin

unread,
Oct 15, 2010, 6:17:18 PM10/15/10
to closure-temp...@googlegroups.com, Closure Templates Discuss
Blank line betwen soy doc and {template}?

Sent from my iPhone

Brad Rice

unread,
Oct 15, 2010, 7:41:26 PM10/15/10
to closure-temp...@googlegroups.com
Ah. In your book, it goes across a page, so I didn't realize that was
important. Thank you.

--
Brad Rice
brad...@gmail.com
~
“Christianity is one beggar telling another beggar where he found
bread.” - D.T. Niles

Brad Rice

unread,
Oct 16, 2010, 9:42:12 AM10/16/10
to closure-temp...@googlegroups.com
Well, I'm proceeding onward, but ran into another issue. When I try to
compile using the books commands I get a dep duplicate error.

Exception: Duplicate provide (example.templates) in
(../closure-library/hello.soy.js, hello.soy.js)

This is how I run the compiler:

python ../closure-library/closure/bin/calcdeps.py --path
../closure-library --path
../closure-templates/javascript/soyutils_usegoog.js --path
hello.soy.js --input hello.js --compiler_jar
../closure-compiler/build/compiler.jar --output_mode compiled
--compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS"
hello-compiled.js

bolinfest

unread,
Oct 16, 2010, 11:20:28 AM10/16/10
to Closure Templates Discuss
It looks like you have created two copies of hello.soy.js: one in the
closure-library directory and one in the directory from which you are
running the Python command. Generally speaking, you should not be
adding files to the closure-library directory. If you delete the copy
of hello.soy.js from closure-library, then I think you will be all
set.

Also, you may want to look into using plovr (http://plovr.com/) as it
will simplify your build command considerably.

On Oct 16, 9:42 am, Brad Rice <bradri...@gmail.com> wrote:
> Well, I'm proceeding onward, but ran into another issue. When I try to
> compile using the books commands I get a dep duplicate error.
>
> Exception: Duplicate provide (example.templates) in
> (../closure-library/hello.soy.js, hello.soy.js)
>
> This is how I run the compiler:
>
> python ../closure-library/closure/bin/calcdeps.py --path
> ../closure-library --path
> ../closure-templates/javascript/soyutils_usegoog.js --path
> hello.soy.js --input hello.js --compiler_jar
> ../closure-compiler/build/compiler.jar --output_mode compiled
> --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS"
> hello-compiled.js
>
>
>
> On Fri, Oct 15, 2010 at 7:41 PM, Brad Rice <bradri...@gmail.com> wrote:
> > Ah. In your book, it goes across a page, so I didn't realize that was
> > important. Thank you.
>
> > On Fri, Oct 15, 2010 at 6:17 PM, Michael Bolin <bolinf...@gmail.com> wrote:
> >> Blank line betwen soy doc and {template}?
>
> >> Sent from my iPhone
>
> > bradri...@gmail.com
> > ~
> > “Christianity is one beggar telling another beggar where he found
> > bread.” - D.T. Niles
>
> --
> Brad Rice
> bradri...@gmail.com

Brad Rice

unread,
Oct 16, 2010, 11:39:20 AM10/16/10
to closure-temp...@googlegroups.com
Thanks, yes I was accidentally in the closure-library folder when I
ran the SoyToJsSrcCompiler.jar and I ran it again. I think I need to
figure out these exception messages.

--
Brad Rice
brad...@gmail.com

Reply all
Reply to author
Forward
0 new messages