Re: Closure book Hello World example

55 views
Skip to first unread message

Michael Bolin

unread,
May 1, 2013, 8:06:39 PM5/1/13
to closure-temp...@googlegroups.com

I don't have time to dig into this right now, but tools for inevitably evolve, which is why I listed the versions of the tools that I used in Chapter 1 (or maybe the introduction?). That said, I don't believe the current tools are all that different, so it's probably a very small tweak.

On May 1, 2013 3:44 PM, "Christian Worley" <chri...@worleydev.com> wrote:
Hi,

I've been following along in the Closure book's Hello World example. When following the template portion of the example I don't arrive at the desired results.

my template:
{namespace example.templates}
/**
* @param greeting
* @param year
*/
{template .welcome}
<h1 id="greeting">{$greeting}</h1>
The year is {$year}.
{/template}

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

creates hello.soy.js containing (notice the null|undefined in the second parameter and the missing var in the object):
// This file was automatically generated from hello.soy.
// Please don't edit this file by hand.

goog.provide('example.templates');

goog.require('soy');
goog.require('soydata');


/**
 * @param {Object.<string, *>=} opt_data
 * @param {(null|undefined)=} opt_ignored
 * @return {string}
 * @notypecheck
 */
example.templates.welcome = function(opt_data, opt_ignored) {
  return '\t<h1 id="greeting">' + soy.$$escapeHtml(opt_data.greeting) + '</h1>The year is ' + soy.$$escapeHtml(opt_data.year) + '.';
};

According to the book the second param and return should be:
* @param {soy.StringBuilder=} opt_sb
* @return {string|undefined}

No errors are thrown in cmd.
Thanks in advance for any help.

--
 
---
You received this message because you are subscribed to the Google Groups "Closure Templates Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John Lenz

unread,
May 1, 2013, 10:32:12 PM5/1/13
to closure-temp...@googlegroups.com

The closure template default mode is no longer to use string builder. You can switch it back but the new default generates smaller faster code.

Reply all
Reply to author
Forward
0 new messages