Questions tagged [google-closure-templates]

Closure Templates are a client- and server-side templating system that helps you dynamically build reusable HTML and UI elements

Closure Templates are a client- and server-side templating system that helps you dynamically build reusable HTML and UI elements. They have a simple syntax that is natural for programmers, and you can customize them to fit your application's needs. In contrast to traditional templating systems, in which you must create one monolithic template per page, you can think of Closure Templates as small components that you compose to form your user interface. You can also use the built-in message support to easily localize your applications.

Closure Templates are implemented for both JavaScript and Java, so that you can use the same templates on both the server and client side. They use a data model and expression syntax that work for either language. For the client side, Closure Templates are precompiled into efficient JavaScript.

What are the benefits of using Closure Templates?

  • Convenience. Closure Templates provide an easy way to build pieces of HTML for your application's UI and help you separate application logic from display.
  • Language-neutral. Closure Templates work with JavaScript or Java. You can write one template and share it between your client- and server-side code.
  • Client-side speed. Closure Templates are compiled to efficient JavaScript functions for maximum client-side performance.
  • Easy to read. You can clearly see the structure of the output HTML from the structure of the template code. Messages for translation are inline for extra readability.
  • Designed for programmers. Templates are simply functions that can call each other. The syntax includes constructs familiar to programmers. You can put multiple templates in one source file.
  • A tool, not a framework. Works well in any web application environment in conjunction with any libraries, frameworks, or other tools.
  • Battle-tested. Closure Templates are used extensively in some of the largest web applications in the world, including Gmail, Google Docs, and Google Shopping.

Source:- https://developers.google.com/closure/templates/

76 questions
0
votes
1 answer

Closure disable URL substitution with autoescape=strict

I am rendering a soy template using Closure for a chrome extension and am having trouble inserting chrome-extension://* links since they are being filtered by soy.$$filterNormalizeUri While normally it would be undesirable to allow…
0
votes
1 answer

Closure Templates generates code that does not use StringBuilder

I recently pull a project from GitHub that included a compile-soy task in its build.xml. The task uses SoyToJsSrcCompiler.jar to compile a couple of soy files into javascript. The project included the target directory so I could see that the…
0
votes
1 answer

Google Fusion Table Mapping Help! - Custom Info Window using Closure Templates

First, some background: I'm working with mapping from Google Fusion Tables and I'm trying to customize the info window using Dynamic Templating, which uses Closure Templates. I'm editing the window from the Configure Map area of my Fusion Table. I'm…
0
votes
1 answer

Cannot modify a value in a Soy template

{let $first: 10 /} // this is a single line soy comment {if $first > 5 } {$first}
{let $first:$first-1 /} {/if} {$first} I tried this, and it prints: 10 10 Ideally, it should print: 10 9 .. Can you please identify what's wrong in my…
sekhar
  • 371
  • 2
  • 10
0
votes
1 answer

Syntax highlighting for .soy or custom file types

I'm using closure templates to minify and generate dynamic html on my website, the only downside is that while editing in Visual Studio there's absolutely zero syntax highlighting. Anyone know of any solutions or how to go about solving this myself?
Ally
  • 4,894
  • 8
  • 37
  • 45
0
votes
0 answers

How to preselect checkboxes with closure templates?

In a closure template I receive 2 lists (divisions, offices) and offices can be associated with some divisions ( divisions.officeLocations[] ). How can I preselect checkboxes (offices from divisions divisions.officeLocations[]) from all the offices…
S.Galarneau
  • 2,194
  • 1
  • 24
  • 26
0
votes
1 answer

How to use the closure template API with the template in string form instead of the File form

The closure template API SoyFileSet.Builder has several ways to define templates that one wants to use. The one I know how to use is the following: SoyFileSet sfs = builder.add(new File("...")).build(); There is a second way to create the…
dexter
  • 530
  • 7
  • 19
0
votes
1 answer

Google Closure Template Bitwise operator

I am using Google Closure template first time. Can we use Bitwise operator in Google Closure Template. I want to use some thing like this: {if $saleStatus.errors & $constant.displayValue}
Amit T
  • 93
  • 1
  • 2
  • 12
0
votes
2 answers

How to loop multiple passed parameters in Google closure template?

Lets say i have this arrays in JS: var array1[]; var array2[]; var array3[]; And those arrays have some values, and I want to pass them to google's closure template. Lets say my closure template's file name is MyArraysTemplate, and I want to target…
Belmark Caday
  • 1,623
  • 3
  • 21
  • 29
0
votes
1 answer

Is it possible to automatically convert javascript to closure template format?

I'm wondering if it's possible to convert javascript to closure template format without having to manually add all of the closure tags/formatting: {namespace example.templates} /** *@param var1 Description *@param var2 Description */ From my…
iliketolearn
  • 670
  • 3
  • 8
  • 25
0
votes
1 answer

How to xlf-translate soy template by plovr?

{msg desc="Says hello and tells user to click a link."} Hello {$userName}! Please click here. {/msg} what set config file or request params in plovr?
constantant
  • 1,192
  • 1
  • 13
  • 25
0
votes
1 answer

HtmlEasy and Silken to serve mobile specific page

I'm busy building a web page where I'm using HtmlEasy and Silken with Google Closure Templates. With ASP.NET MVC4 there is a technique of serving a mobile version of a web page by changing the file name to .mobile.. So it is not just the same…
user1980175
0
votes
1 answer

Best Way to output SoyTemplates from a Servlet

What is the best waya to render or output Soy Templates from closure-templates to a browser? Currently i have the following: package de.envisia.erp.web.servlet; import java.io.File; import java.io.IOException; import…
Christian Schmitt
  • 837
  • 16
  • 47
0
votes
1 answer

Sending compiled objects to Closure Templates

If I call a template from JavaScript with: namespace.template(record); where record is an instance of: /** @typedef {{var: string}} */ and I use the Google Closure Compiler in advanced mode, which rewrites var, then how can I receive var in the…
0
votes
1 answer

How to integrate Print Directive of Google Closure Template (Soy)

I would like to know how to integrate a print plugin of Google Closure Template, a.k.a. Soy, step by step if you can, mainly because I'm pretty bad at Java. Below page explains how to do that, but I need more detail…