much stuffs
This commit is contained in:
2
Makefile
2
Makefile
@@ -7,7 +7,9 @@ build:
|
|||||||
@echo "Copying templates and static..."
|
@echo "Copying templates and static..."
|
||||||
mkdir -p $(BUILD_DIR)/templates
|
mkdir -p $(BUILD_DIR)/templates
|
||||||
mkdir -p $(BUILD_DIR)/static
|
mkdir -p $(BUILD_DIR)/static
|
||||||
|
mkdir -p $(BUILD_DIR)/pages
|
||||||
cp -r templates/* $(BUILD_DIR)/templates/
|
cp -r templates/* $(BUILD_DIR)/templates/
|
||||||
|
cp -r pages/* $(BUILD_DIR)/pages/
|
||||||
cp -r static/* $(BUILD_DIR)/static/
|
cp -r static/* $(BUILD_DIR)/static/
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -13,12 +13,13 @@ func pageHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
path = "/home"
|
path = "/home"
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(
|
tmpl, err := template.Must(template.ParseGlob("templates/*.html")).Clone()
|
||||||
filepath.Join("templates/layout.html"),
|
if err != nil {
|
||||||
filepath.Join("templates/header.html"),
|
http.NotFound(w, r)
|
||||||
filepath.Join("templates/footer.html"),
|
return
|
||||||
filepath.Join("pages/"+path+".html"),
|
}
|
||||||
)
|
|
||||||
|
_, err = tmpl.ParseFiles(filepath.Join("pages", path+".html"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user