Skip to content

Commit

Permalink
fix examples for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Oct 30, 2014
1 parent c819b85 commit 004ca18
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 51 deletions.
2 changes: 1 addition & 1 deletion examples/gen/helper/footer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

func Footer() string {
var _buffer bytes.Buffer
_buffer.WriteString("<div>copyright 2014</div>\n")
_buffer.WriteString("<div>copyright 2014</div>")

return _buffer.String()
}
2 changes: 1 addition & 1 deletion examples/gen/helper/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

func Header() string {
var _buffer bytes.Buffer
_buffer.WriteString("<div>Page Header</div>\n")
_buffer.WriteString("<div>Page Header</div>")

return _buffer.String()
}
13 changes: 6 additions & 7 deletions examples/gen/helper/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (

func Msg(u *User) string {
var _buffer bytes.Buffer
_buffer.WriteString("\n\n\n")
{
username := u.Name
if u.Email != "" {
username += "(" + u.Email + ")"
}

username := u.Name
if u.Email != "" {
username += "(" + u.Email + ")"
}

_buffer.WriteString("\n<div class=\"welcome\">\n<h4>Hello ")
_buffer.WriteString(gorazor.HTMLEscape(username))
_buffer.WriteString("</h4>\n\n<div>")
_buffer.WriteString((u.Intro))
_buffer.WriteString("</div>\n</div>\n\n")
_buffer.WriteString("</div>\n</div>")

return _buffer.String()
}
70 changes: 30 additions & 40 deletions examples/gen/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import (

func Home(totalMessage int, u *User) string {
var _buffer bytes.Buffer
_buffer.WriteString("\n\n\n")
_buffer.WriteString((helper.Header()))
_buffer.WriteString("\n")
_buffer.WriteString((helper.Msg(u)))
_buffer.WriteString("\n\n")
for i := 0; i < 2; i++ {
if totalMessage > 0 {
if totalMessage == 1 {
Expand All @@ -40,60 +37,55 @@ func Home(totalMessage int, u *User) string {

}
}
_buffer.WriteString("\n\n\n")
{
for i := 0; i < 2; i++ {
if totalMessage > 0 {
if totalMessage == 1 {

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 1 message</p>")

} else {
for i := 0; i < 2; i++ {
if totalMessage > 0 {
if totalMessage == 1 {

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has ")
_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(totalMessage)))
_buffer.WriteString(" messages</p>")
_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 1 message</p>")

}
} else {

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has no messages</p>")
_buffer.WriteString(" has ")
_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(totalMessage)))
_buffer.WriteString(" messages</p>")

}
}
}
_buffer.WriteString("\n\n")
{
switch totalMessage {
case 1:
} else {

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 1 message</p>")
_buffer.WriteString(" has no messages</p>")

case 2:
}
}

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 2 messages</p>")
switch totalMessage {
case 1:

default:
_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 1 message</p>")

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has no messages</p>")
case 2:

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has 2 messages</p>")

default:

_buffer.WriteString("<p>")
_buffer.WriteString(gorazor.HTMLEscape(u.Name))
_buffer.WriteString(" has no messages</p>")

}
}
_buffer.WriteString("\n\n")

_buffer.WriteString((helper.Footer()))
_buffer.WriteString("\n\n")

title := func() string {
var _buffer bytes.Buffer
Expand All @@ -104,14 +96,12 @@ func Home(totalMessage int, u *User) string {

return _buffer.String()
}
_buffer.WriteString("\n\n")

side := func() string {
var _buffer bytes.Buffer

return _buffer.String()
}
_buffer.WriteString("\n")

return layout.Base(_buffer.String(), title(), side())
}
4 changes: 2 additions & 2 deletions examples/gen/layout/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (

func Base(body string, title string, side string) string {
var _buffer bytes.Buffer
_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\" />\n")
_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\" />")
_buffer.WriteString((title))
_buffer.WriteString("\n</head>\n<body>\n<div>")
_buffer.WriteString((body))
_buffer.WriteString("</div>\n<div>")
_buffer.WriteString((side))
_buffer.WriteString("</div>\n</body>\n</html>\n")
_buffer.WriteString("</div>\n</body>\n</html>")

return _buffer.String()
}

0 comments on commit 004ca18

Please sign in to comment.