Skip to content

Commit

Permalink
03-Template-Advance combination
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfy committed Sep 7, 2018
1 parent 50e5028 commit 134267d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ type User struct {

// Post struct
type Post struct {
User User
User
Body string
}

// IndexViewModel struct
type IndexViewModel struct {
Title string
User User
User
Posts []Post
}

Expand Down
4 changes: 2 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{{end}}
</head>
<body>
<h1>Hello, {{.User.Username}}!</h1>
<h1>Hello, {{.Username}}!</h1>
{{range .Posts}}
<div><p>{{ .User.Username }} says: <b>{{ .Body }}</b></p></div>
<div><p>{{ .Username }} says: <b>{{ .Body }}</b></p></div>
{{end}}

</body>
Expand Down

0 comments on commit 134267d

Please sign in to comment.