Skip to content

Instantly share code, notes, and snippets.

@wemgl
Created March 10, 2019 14:38
Show Gist options
  • Save wemgl/4df43f24aa6eca4c63257d2b96b3d9f7 to your computer and use it in GitHub Desktop.
Save wemgl/4df43f24aa6eca4c63257d2b96b3d9f7 to your computer and use it in GitHub Desktop.
Example of simple HTML templates in Go
{{define "base"}}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" type="image/x-icon" href="/public/assets/images/favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700">
<link rel="stylesheet" type="text/css" href="/public/assets/styles/style.css">
<title>{{.Title}}</title>
</head>
<body>
{{template "body" .}}
</body>
</html>
{{end}}
{{define "body"}}
<h1 class="hidden">Simple Server Body</h1>
<header class="header">
<h1 class="hidden">Header</h1>
<img class="logo" src="/public/assets/images/logo.svg">
<nav class="navigation">
<h2 class="hidden">Navigation</h2>
<ul class="navigation__items">
<li class="navigation__item">Home</li>
<li class="navigation__item">About</li>
<li class="navigation__item">Contact</li>
</ul>
</nav>
</header>
<main>
<h1 class="hidden">Main Content</h1>
<article class="hero">
<h2 class="hidden">Main Article</h2>
<section class="hero__text">
<h3 class="hidden">Main section</h3>
<p class="salutation salutation--bg">
<span class="salutation__greeting">{{.BusinessName}}</span>
<span class="salutation__message">{{.Slogan}}</span>
</p>
<div class="js-container"></div>
</section>
</article>
</main>
<script type="text/javascript" src="/public/assets/scripts/main.js"></script>
{{end}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment