forked from goffee/cup
template env
This commit is contained in:
parent
11272c4a85
commit
017ef4c066
4 changed files with 32 additions and 8 deletions
|
|
@ -6,13 +6,39 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"git.smarteching.com/goffee/core"
|
||||
"git.smarteching.com/goffee/core/template/components"
|
||||
)
|
||||
|
||||
// Show home page
|
||||
func WelcomeHome(c *core.Context) *core.Response {
|
||||
message := "{\"message\": \"Welcome to Goffee\"}"
|
||||
return c.Response.Json(message)
|
||||
|
||||
// check if template engine is enable
|
||||
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||
if TemplateEnableStr == "" {
|
||||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
}
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: "Welcome to Goffee",
|
||||
},
|
||||
}
|
||||
|
||||
return c.Response.Template("basic.html", tmplData)
|
||||
} else {
|
||||
message := "{\"message\": \"Welcome to Goffee\"}"
|
||||
return c.Response.Json(message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show dashboard
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue