O'Reilly logo

Go Web Development Cookbook by Arpit Aggarwal

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

How to do it…

In this recipe, we are going to create a first-template.html with a couple of placeholders whose value will be injected by the template engine at runtime. Perform the following steps:

  1. Create first-template.html inside the templates directory by executing the following Unix command:
$ mkdir templates && cd templates && touch first-template.html
  1. Copy the following content to first-template.html:
<html>  <head>    <meta charset="utf-8">    <title>First Template</title>    <link rel="stylesheet" href="/static/stylesheets/main.css">  </head>  <body>    <h1>Hello {{.Name}}!</h1>    Your Id is {{.Id}}  </body></html>

The preceding template has two placeholders, {{.Name}} and {{.Id}}, whose values will be substituted or injected by the template engine ...

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