-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathmain.go
More file actions
32 lines (24 loc) · 662 Bytes
/
main.go
File metadata and controls
32 lines (24 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"fmt"
"html/template"
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
tmpl := iris.Pug("./templates", ".pug")
tmpl.Reload(true) // reload templates on each request (development mode)
tmpl.AddFunc("bold", func(s string) (template.HTML, error) { // add your template func here.
return template.HTML("<b>" + s + "</b>"), nil
})
app.RegisterView(tmpl)
app.Get("/", index)
// http://localhost:8080
app.Listen(":8080")
}
func index(ctx iris.Context) {
if err := ctx.View("index.pug"); err != nil {
ctx.HTML(fmt.Sprintf("<h3>%s</h3>", err.Error()))
return
}
}