mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 20:41:57 +00:00
Update vendor for Pug (Jade) Parser and add Iris + Pug examples in the _examples/view folder, relative to https://github.com/kataras/iris/issues/1003
Former-commit-id: e26a5701e00ec055f3bcf693c1980c7d22147310
This commit is contained in:
28
_examples/view/template_pug_2/main.go
Normal file
28
_examples/view/template_pug_2/main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
)
|
||||
|
||||
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.Run(iris.Addr(":8080"))
|
||||
}
|
||||
|
||||
func index(ctx iris.Context) {
|
||||
ctx.View("index.pug")
|
||||
}
|
||||
2
_examples/view/template_pug_2/templates/footer.pug
Normal file
2
_examples/view/template_pug_2/templates/footer.pug
Normal file
@@ -0,0 +1,2 @@
|
||||
#footer
|
||||
p Copyright (c) foobar
|
||||
4
_examples/view/template_pug_2/templates/header.pug
Normal file
4
_examples/view/template_pug_2/templates/header.pug
Normal file
@@ -0,0 +1,4 @@
|
||||
head
|
||||
title My Site
|
||||
<!-- script(src='/javascripts/jquery.js')
|
||||
script(src='/javascripts/app.js') -->
|
||||
7
_examples/view/template_pug_2/templates/index.pug
Normal file
7
_examples/view/template_pug_2/templates/index.pug
Normal file
@@ -0,0 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
include templates/header.pug
|
||||
body
|
||||
h1 My Site
|
||||
p {{ bold "Welcome to my super lame site."}}
|
||||
include templates/footer.pug
|
||||
Reference in New Issue
Block a user