O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The cars listing demo

In the cars listing demo, we will populate a table with rows that are rendered from an inline client-side Go template. In our example, the table will be a list of cars, and we will obtain the cars to be shown in the table from a slice of cars. We will then encode the slice of cars using gob encoding and transmit the data to the web server instance over an XHR call.

Client-side template rendering has many benefits:

  • CPU usage on the web server is rendered, which is caused by server-side template rendering
  • Full page reloads are not required to render the client-side template
  • Bandwidth consumption is reduced by rendering the template on the client-side

Let's open up the cars.html source file in the shared/templates/carsdemo_page.tmpl ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required