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