Skip to content

Commit

Permalink
added 30 using layouts now
Browse files Browse the repository at this point in the history
  • Loading branch information
jagottsicher committed Mar 3, 2023
1 parent e8c805e commit 7d6fe86
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

// rendernTemplate serves as a wrapper and renders
// a template from folder /templates to a desired writer
// a layout and a template from folder /templates to a desired writer
func RenderTemplate(w http.ResponseWriter, tpml string) {
parsedTemplate, _ := template.ParseFiles("./templates/" + tpml)
parsedTemplate, _ := template.ParseFiles("./templates/"+tpml, "./templates/base-layout.tpml")
err := parsedTemplate.Execute(w, nil)
if err != nil {
fmt.Println("error parsing template:", err)
Expand Down
16 changes: 4 additions & 12 deletions templates/about-page.tpml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
{{template "base" .}}

{{define "content"}}
<div class="container">
<div class="row">
<div class="col">
Expand All @@ -16,5 +9,4 @@
</div>
</div>
</div>
</body>
</html>
{{end}}
24 changes: 24 additions & 0 deletions templates/base-layout.tpml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{define "base"}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<title>Document</title>
{{block "css" .}}

{{end}}
</head>
<body>
{{block "content" .}}

{{end}}

{{block "js" .}}

{{end}}
</body>
</html>
{{end}}
16 changes: 4 additions & 12 deletions templates/home-page.tpml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
{{template "base" .}}

{{define "content"}}
<div class="container">
<div class="row">
<div class="col">
Expand All @@ -16,5 +9,4 @@
</div>
</div>
</div>
</body>
</html>
{{end}}

0 comments on commit 7d6fe86

Please sign in to comment.