aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-04-22 23:07:35 -0400
committerbnewbold <bnewbold@robocracy.org>2012-04-22 23:07:35 -0400
commit7b6696714142de8deeb5ef4f144ac3ecf8116e3e (patch)
tree5343926cb2b008219e43c1c6e9ce0252509ffc6a
parentf9ef9d242c4d1de392269379598d2a05109d44ad (diff)
downloadbommom-7b6696714142de8deeb5ef4f144ac3ecf8116e3e.zip
bommom-7b6696714142de8deeb5ef4f144ac3ecf8116e3e.tar.gz
basic HTML templating
-rw-r--r--serve.go4
-rw-r--r--templates/base.html8
-rw-r--r--templates/home.html10
3 files changed, 12 insertions, 10 deletions
diff --git a/serve.go b/serve.go
index dff2006..f54ca0e 100644
--- a/serve.go
+++ b/serve.go
@@ -49,8 +49,8 @@ func serveCmd() {
var err error
// load and parse templates
- tmplHome = template.Must(template.ParseFiles(*templatePath + "/home.html"))
- tmplView = template.Must(template.ParseFiles(*templatePath + "/view.html"))
+ baseTmplPath := *templatePath + "/base.html"
+ tmplHome = template.Must(template.ParseFiles(*templatePath + "/home.html", baseTmplPath))
if err != nil {
log.Fatal(err)
}
diff --git a/templates/base.html b/templates/base.html
new file mode 100644
index 0000000..538d7db
--- /dev/null
+++ b/templates/base.html
@@ -0,0 +1,8 @@
+{{ define "HEADER" }}<html>
+<head>
+<title>bombom</title>
+<link rel="stylesheet" type="text/css" href="/static/default.css"></link>
+</head>
+<body>{{ end }}
+{{ define "FOOTER" }}</body>
+</html>{{ end }}
diff --git a/templates/home.html b/templates/home.html
index 0cc420e..1298241 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -1,9 +1,3 @@
-<html>
-<head>
-<title>bombom</title>
-<link rel="stylesheet" type="text/css" href="/static/default.css"></link>
-</head>
-<body>
+{{ template "HEADER" }}
<h1>Home Page</h1>
-</body>
-</html>
+{{ template "FOOTER" }}