-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fogo-sh/seperate-template-logic
break out template and static logic into own pkgs
- Loading branch information
Showing
4 changed files
with
51 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package static | ||
|
||
import "embed" | ||
|
||
//go:embed static | ||
var StaticFS embed.FS |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package templates | ||
|
||
import "html/template" | ||
|
||
type PageTemplateData struct { | ||
Title string | ||
Content template.HTML | ||
} | ||
|
||
var pageTemplateContent = `<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{ .Title }}</title> | ||
<link rel="stylesheet" href="/assets/css/main.css"> | ||
</head> | ||
<body> | ||
<h1>{{ .Title }}</h1> | ||
{{ .Content }} | ||
</body> | ||
</html>` | ||
|
||
var PageTemplate *template.Template | ||
|
||
type PageData struct { | ||
Title string | ||
Content template.HTML | ||
} | ||
|
||
func init() { | ||
t, err := template.New("page").Parse(pageTemplateContent) | ||
if err != nil { | ||
panic(err) | ||
} | ||
PageTemplate = t | ||
} |