Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
03-Template-Advance template inheritance
- Loading branch information
Showing
4 changed files
with
60 additions
and
18 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,13 @@ | ||
<html> | ||
<head> | ||
{{if .Title}} | ||
<title>{{.Title}} - blog</title> | ||
{{else}} | ||
<title>Welcome to blog!</title> | ||
{{end}} | ||
</head> | ||
<body> | ||
<div>Blog: <a href="/">Home</a></div> | ||
{{template "content" .}} | ||
</body> | ||
</html> |
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,7 @@ | ||
{{define "content"}} | ||
<h1>Hello, {{.User.Username}}!</h1> | ||
|
||
{{range .Posts}} | ||
<div><p>{{ .User.Username }} says: <b>{{ .Body }}</b></p></div> | ||
{{end}} | ||
{{end}} |
This file was deleted.
Oops, something went wrong.
hello ,作者。我有个小小的建议,在
for
循环中使用func () {}()
来包装里面文件操作的代码,保证使用defer
不会产生延迟关闭文件的情况发生。具体可以查看 PR #bonfy/go-mega#2