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
1
vote
3 answers

Using google closure soy templates in php

Is there any possibility to use Google closure soy templates with PHP like JAVA? Some class generator which generates PHP classes instead of JAVA classes or feature to using soy templates in php code? I like idea of using same templates in both…
vaclav_o
  • 1,705
  • 3
  • 15
  • 24
1
vote
2 answers

How to get the language specific messages using google closure template

Am trying to implement internationalization support to my project for this people suggested google Closure Templates.but am very new to closure templates.am trying to get the language specific messages using closure template but am not getting…
0
votes
2 answers

What is the correct way to use soyutils with Google Closure?

I am trying to use Google Closure templates (Soy) with Google Closure. I am including the soyutils_usegoog.js utilities file as instructed. This file provides a number of utilities used by the generated templates, notably soy.StringBuilder. Here's…
0
votes
1 answer

Navigation across multiple sites / code languages with 1 source

Scenario: We have a client who has multiple large sites, a huge number of stakeholders and decision makers which rules out a redevelopment involving all of them at the moment. Some sites are php, some are coldfusion and others are ASP.NET. We are…
Jackson
  • 1,194
  • 3
  • 16
  • 26
0
votes
1 answer

Getting error about duplicate template definitions in file with a single template definition, Google closure templates

I'm using google closure templates in java. I'm getting the following error when using the SoyFileSet builder to compile my templates to a single java object (I have many template files which I compile to a java…
Dave
  • 6,141
  • 2
  • 38
  • 65
0
votes
0 answers

Bazel CSS not being served from closure_js_binary

Project structure looks something along the lines of: . ├── UI │ ├── BUILD │ └── app.js └── component ├── BUILD ├── component.soy ├── component.js └── component.gss The app's BUILD file looks like: closure_js_library( name =…
0
votes
1 answer

Issue with Closure Template (soy templates) rendering via Javascript & jQuery

I'm using javascript along with jQuery to render the closure templates (soy templates). I'm follwing its hello world example. My jsfiddle here . As described in the example, the following code…
0
votes
1 answer

Closure templates - create a reusable alias for complicated `record` definition

I have a soy template that looks like {template .fullView} {@param people: list<[age:int, name:string]>} {call .headers} {param people: $queries /} {/call} {call .content} {param people: $queries /} {/call} {/template} {template…
user3875080
  • 63
  • 1
  • 5
0
votes
1 answer

What's the right way to create parameters in Soy V2?

Here is my code: {template .someTemplate} {@param? icon : string} /** CSS class that loads and styles the icon */ {@param? headlineHtml : any} /** Headline text with optional html for styling */ {@param? textHtml : any} /** Subtext with…
Reagankm
  • 4,780
  • 9
  • 27
  • 52
0
votes
1 answer

Strange behaviour involving Closure commands and "text-align:justify"

I have some divs within a Soy template that I want to be evenly spaced, horizontally. Here is what does work: CSS (nomenclature simplified for this example): .list-of-things { position: relative; text-align: justify; } .list-of-things::after { …
0
votes
1 answer

Google Closure Templates variable variables

Situation: context contains such fields as testExecutionKey1, testExecutionKey2 .. testExecutionKey10 I want to check them for null, but do it the nice way - in for loop I need to access $context.testExecutionKey1..10 inside the loop, where number…
A. Knorre
  • 134
  • 1
  • 6
0
votes
1 answer

Using event at google closure template

I have some problems about google closure template. I'm doing a navigator of websites, which a little kind of complex and with multiple events; now i am using template to create navigator DOM structure but fail to hand events because i don't know if…
Lumaskcete
  • 670
  • 6
  • 12
0
votes
1 answer

Update value in soy template declared with let

I have one value that is tied to a flag that comes from a config file that I need to show in my soy template. It is either true or false. If true, the value needs to be "x" (for example, but it is a string) If false, the value needs to be ""…
0
votes
1 answer

How to add multiple CSS classes to HTML node in Closure template (soy)?

In a template I need to assign more than one CSS class to a div. However, when I try something like the following, the Closure compiler seems to wrap only the first class in quotation marks, resulting in the browser ignoring the rest.
0
votes
1 answer

Google Closure Library can't get dependencies loading correctly in simple example

I'm trying to get google Closure Library with Closure Templates working however when I run my app it throws an error soyutils_usegoog.js:74 Uncaught TypeError: Cannot read property 'StringBuffer' of undefined. I've research everything, added the…