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 ...