What's New in Closure Templates

  1. Updates
  2. To Be Removed

Updates

Closure Templates Release April 2014

  • New {@param} command allows for strongly-typed parameter declarations.
  • New autoescape="strict" option for improved XSS protection.
  • {fallback} option for localized messages.

Closure Templates Release December 2012

  • New error check: In calls where attribute data="..." is not used, the compiler now checks that all required parameters of the callee template are passed. Thus, you might need to make minor fixes to your code in order to use the latest compiler release.
  • Cleaner handling of null and undefined values:
  • Command fallbackmsg enables you to change a message in-place and automatically continue to use the translation for the old message until the new message is translated.
  • Command let defines an alias for an intermediate value in your template.
  • Command alias declares an alias for a namespace.
  • Delegate variants allow you to select which delegate implementation to call dynamically at each call site.
  • New doc chapters list all functions and print directives in one page.
  • New compiler flags for the SoyToJsSrcCompiler.
  • The default code generation style for the SoyToJsSrcCompiler has been changed to concat.
  • Clarified the difference between the two forms of the param command syntax (one is for arbitrary values, the other is for rendering to a string).

To Be Removed

Here are some behaviors that will no longer be supported at some point in the future. Please remove any usages of or dependence on these behaviors.

  • Change all template tags to use the syntax form {template <template_name> ...}, where the template name is a dot followed by an identifier (i.e. partial name, not full name).
  • Change all call tags to use the syntax form {call <template_name> ...}, where the template name is either a dot followed by an identifier (i.e. partial name) or multiple identifiers joined by dots (i.e. full name). In particular, it should never be a single identifier without any dots.
  • Eliminate all existing external calls from your templates, then set the compiler flag --allowExternalCalls false. External calls are calls to templates that aren't defined in the same bundle of Soy files being compiled together. Their existence prevents the Soy compiler from being able to accurately analyze your code.
  • If you use delegates, add the attribute allowemptydefault="true/false" to all existing and future delcall tags.
  • In the css tag, it's incorrect to include 2 names. Change class="{css classA classB}" to class="{css classA} {css classB}".
  • In the Tofu backend (Java usage), currently $aaa.bbb evaluates to undefined when $aaa is undefined or null. This will become a render time exception in the future. Instead, use $aaa?.bbb whenever $aaa has a possibility of being undefined or null.