You can select to include elements via the code

This commit is contained in:
Nathanael Hough 2025-10-22 22:14:18 -05:00
parent 3cc1aa151f
commit 9d69a17d4e
4 changed files with 96 additions and 2 deletions

38
main.go
View File

@ -1,7 +1,41 @@
package main package main
import "fmt" import (
"fmt"
"html/template"
"net/http"
)
type Item struct {
ID string
Title string
}
type PageData struct {
Title string
// Items []Item
Selected map[string]bool
}
var tmpl = template.Must(template.ParseGlob("templates/*.html"))
func main() { func main() {
fmt.Println("Hello World")
fmt.Println("serving on localhost:8080")
http.HandleFunc("/", indexHandler)
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.ListenAndServe(":8080", nil)
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
selected := map[string]bool{"lords_prayer": false, "collect_for_purity": true}
data := PageData{
Title: "The Order for Holy Communion",
Selected: selected,
}
if err := tmpl.ExecuteTemplate(w, "communion.html", data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
} }

0
static/css/style.css Normal file
View File

25
templates/communion.html Normal file
View File

@ -0,0 +1,25 @@
{{/* file: templates/index.html */}}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<h1>{{.Title}}</h1>
<section id="lord_prayer">
{{if index .Selected "lords_prayer"}}
{{template "lords_prayer"}}
{{end}}
</section>
<section id="collect_for_purity">
{{if index .Selected "collect_for_purity"}}
{{template "collect_for_purity"}}
{{end}}
</section>
</body>
</html>

35
templates/partials.html Normal file
View File

@ -0,0 +1,35 @@
{{define "lords_prayer"}}
<h2>Lord's Prayer</h2>
<p>OUR Father, who art in heaven, Hallowed be thy Name.
Thy kingdom come. Thy will be done, On earth as it
is in heaven. Give us this day our daily bread. And forgive
us our trespasses, As we forgive those who trespass against
us. And lead us not into temptation, But deliver us from
evil. Amen.
</p>
{{end}}
{{define "collect_for_purity"}}
<h2>
The Collect.
</h2>
<p>
ALMIGHTY God, unto whom all hearts are open, all desires known, and from whom no secrets are hid; Cleanse the thoughts of our hearts by the inspira-
tion of thy Holy Spirit, that we may perfectly love thee, and worthily magnify thy holy Name; through Christ our Lord. Amen.
</p>
<p class="rubric">
¶ Then shall the Priest, turning to the People, rehearse distinctly The Ten Commandments; and the People, still kneeling, shall, after every
Commandment, ask God mercy for their transgressions for the time past, and grace to keep the law for the time to come.
</p>
<p class="rubric">
¶ And Note, That in rehearsing The Ten Commandments, the Priest may omit that part of the Commandment which is inset.
</p>
<p class="rubric">
¶ The Decalogue may be omitted, provided it be said at least one Sunday in each month. But Note, That whenever it is omitted, the Priest shall say the Summary
of the Law, beginning, Hear what our Lord Jesus Christ saith.
</p>
{{end}}