mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 13:05:56 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
36
_examples/view/quicktemplate/templates/base.qtpl
Normal file
36
_examples/view/quicktemplate/templates/base.qtpl
Normal file
@@ -0,0 +1,36 @@
|
||||
This is our templates' base implementation.
|
||||
|
||||
{% interface
|
||||
Partial {
|
||||
Body()
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
Template writes a template implementing the Partial interface.
|
||||
{% func Template(p Partial) %}
|
||||
<html>
|
||||
<head>
|
||||
<title>Quicktemplate integration with Iris</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Header contents here...
|
||||
</div>
|
||||
|
||||
<div style="margin:10px;">
|
||||
{%= p.Body() %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<footer>
|
||||
Footer contents here...
|
||||
</footer>
|
||||
</html>
|
||||
{% endfunc %}
|
||||
|
||||
|
||||
Base template implementation. Other pages may inherit from it if they need
|
||||
overriding only certain Partial methods.
|
||||
{% code type Base struct {} %}
|
||||
{% func (b *Base) Body() %}This is the base body{% endfunc %}
|
||||
147
_examples/view/quicktemplate/templates/base.qtpl.go
Normal file
147
_examples/view/quicktemplate/templates/base.qtpl.go
Normal file
@@ -0,0 +1,147 @@
|
||||
// This file is automatically generated by qtc from "base.qtpl".
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
// This is our templates' base implementation.
|
||||
//
|
||||
|
||||
//line base.qtpl:3
|
||||
|
||||
package templates
|
||||
|
||||
//line base.qtpl:3
|
||||
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line base.qtpl:3
|
||||
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line base.qtpl:4
|
||||
|
||||
type Partial interface {
|
||||
//line base.qtpl:4
|
||||
Body() string
|
||||
//line base.qtpl:4
|
||||
StreamBody(qw422016 *qt422016.Writer)
|
||||
//line base.qtpl:4
|
||||
WriteBody(qq422016 qtio422016.Writer)
|
||||
//line base.qtpl:4
|
||||
|
||||
}
|
||||
|
||||
// Template writes a template implementing the Partial interface.
|
||||
|
||||
//line base.qtpl:11
|
||||
|
||||
func StreamTemplate(qw422016 *qt422016.Writer, p Partial) {
|
||||
//line base.qtpl:11
|
||||
qw422016.N().S(`
|
||||
<html>
|
||||
<head>
|
||||
<title>Quicktemplate integration with Iris</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Header contents here...
|
||||
</div>
|
||||
|
||||
<div style="margin:10px;">
|
||||
`)
|
||||
//line base.qtpl:22
|
||||
p.StreamBody(qw422016)
|
||||
//line base.qtpl:22
|
||||
qw422016.N().S(`
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<footer>
|
||||
Footer contents here...
|
||||
</footer>
|
||||
</html>
|
||||
`)
|
||||
//line base.qtpl:30
|
||||
|
||||
}
|
||||
|
||||
//line base.qtpl:30
|
||||
|
||||
func WriteTemplate(qq422016 qtio422016.Writer, p Partial) {
|
||||
//line base.qtpl:30
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line base.qtpl:30
|
||||
StreamTemplate(qw422016, p)
|
||||
//line base.qtpl:30
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line base.qtpl:30
|
||||
|
||||
}
|
||||
|
||||
//line base.qtpl:30
|
||||
|
||||
func Template(p Partial) string {
|
||||
//line base.qtpl:30
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line base.qtpl:30
|
||||
WriteTemplate(qb422016, p)
|
||||
//line base.qtpl:30
|
||||
qs422016 := string(qb422016.B)
|
||||
//line base.qtpl:30
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line base.qtpl:30
|
||||
return qs422016
|
||||
//line base.qtpl:30
|
||||
|
||||
}
|
||||
|
||||
// Base template implementation. Other pages may inherit from it if they need
|
||||
// overriding only certain Partial methods.
|
||||
|
||||
//line base.qtpl:35
|
||||
|
||||
type Base struct{}
|
||||
|
||||
//line base.qtpl:36
|
||||
|
||||
func (b *Base) StreamBody(qw422016 *qt422016.Writer) {
|
||||
//line base.qtpl:36
|
||||
|
||||
qw422016.N().S(`This is the base body`)
|
||||
}
|
||||
|
||||
//line base.qtpl:36
|
||||
//line base.qtpl:36
|
||||
|
||||
func (b *Base) WriteBody(qq422016 qtio422016.Writer) {
|
||||
//line base.qtpl:36
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line base.qtpl:36
|
||||
b.StreamBody(qw422016)
|
||||
//line base.qtpl:36
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line base.qtpl:36
|
||||
|
||||
}
|
||||
|
||||
//line base.qtpl:36
|
||||
|
||||
func (b *Base) Body() string {
|
||||
//line base.qtpl:36
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line base.qtpl:36
|
||||
b.WriteBody(qb422016)
|
||||
//line base.qtpl:36
|
||||
qs422016 := string(qb422016.B)
|
||||
//line base.qtpl:36
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line base.qtpl:36
|
||||
return qs422016
|
||||
//line base.qtpl:36
|
||||
|
||||
}
|
||||
14
_examples/view/quicktemplate/templates/hello.qtpl
Normal file
14
_examples/view/quicktemplate/templates/hello.qtpl
Normal file
@@ -0,0 +1,14 @@
|
||||
Hello template, implements the Partial's methods.
|
||||
|
||||
{% code
|
||||
type Hello struct {
|
||||
Vars map[string]interface{}
|
||||
}
|
||||
%}
|
||||
|
||||
{% func (h *Hello) Body() %}
|
||||
<h1>{%v h.Vars["message"] %}</h1>
|
||||
<div>
|
||||
Hello <b>{%v h.Vars["name"] %}!</b>
|
||||
</div>
|
||||
{% endfunc %}
|
||||
82
_examples/view/quicktemplate/templates/hello.qtpl.go
Normal file
82
_examples/view/quicktemplate/templates/hello.qtpl.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// This file is automatically generated by qtc from "hello.qtpl".
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
// Hello template, implements the Partial's methods.
|
||||
//
|
||||
|
||||
//line hello.qtpl:3
|
||||
|
||||
package templates
|
||||
|
||||
//line hello.qtpl:3
|
||||
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line hello.qtpl:3
|
||||
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line hello.qtpl:4
|
||||
|
||||
type Hello struct {
|
||||
Vars map[string]interface{}
|
||||
}
|
||||
|
||||
//line hello.qtpl:9
|
||||
|
||||
func (h *Hello) StreamBody(qw422016 *qt422016.Writer) {
|
||||
//line hello.qtpl:9
|
||||
qw422016.N().S(`
|
||||
<h1>`)
|
||||
//line hello.qtpl:10
|
||||
qw422016.E().V(h.Vars["message"])
|
||||
//line hello.qtpl:10
|
||||
qw422016.N().S(`</h1>
|
||||
<div>
|
||||
Hello <b>`)
|
||||
//line hello.qtpl:12
|
||||
qw422016.E().V(h.Vars["name"])
|
||||
//line hello.qtpl:12
|
||||
qw422016.N().S(`!</b>
|
||||
</div>
|
||||
`)
|
||||
//line hello.qtpl:14
|
||||
|
||||
}
|
||||
|
||||
//line hello.qtpl:14
|
||||
|
||||
func (h *Hello) WriteBody(qq422016 qtio422016.Writer) {
|
||||
//line hello.qtpl:14
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line hello.qtpl:14
|
||||
h.StreamBody(qw422016)
|
||||
//line hello.qtpl:14
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line hello.qtpl:14
|
||||
|
||||
}
|
||||
|
||||
//line hello.qtpl:14
|
||||
|
||||
func (h *Hello) Body() string {
|
||||
//line hello.qtpl:14
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line hello.qtpl:14
|
||||
h.WriteBody(qb422016)
|
||||
//line hello.qtpl:14
|
||||
qs422016 := string(qb422016.B)
|
||||
//line hello.qtpl:14
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line hello.qtpl:14
|
||||
return qs422016
|
||||
//line hello.qtpl:14
|
||||
|
||||
}
|
||||
12
_examples/view/quicktemplate/templates/index.qtpl
Normal file
12
_examples/view/quicktemplate/templates/index.qtpl
Normal file
@@ -0,0 +1,12 @@
|
||||
Index template, implements the Partial's methods.
|
||||
|
||||
{% code
|
||||
type Index struct {}
|
||||
%}
|
||||
|
||||
{% func (i *Index) Body() %}
|
||||
<h1>Index Page</h1>
|
||||
<div>
|
||||
This is our index page's body.
|
||||
</div>
|
||||
{% endfunc %}
|
||||
72
_examples/view/quicktemplate/templates/index.qtpl.go
Normal file
72
_examples/view/quicktemplate/templates/index.qtpl.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// This file is automatically generated by qtc from "index.qtpl".
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
// Index template, implements the Partial's methods.
|
||||
//
|
||||
|
||||
//line index.qtpl:3
|
||||
|
||||
package templates
|
||||
|
||||
//line index.qtpl:3
|
||||
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line index.qtpl:3
|
||||
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line index.qtpl:4
|
||||
|
||||
type Index struct{}
|
||||
|
||||
//line index.qtpl:7
|
||||
|
||||
func (i *Index) StreamBody(qw422016 *qt422016.Writer) {
|
||||
//line index.qtpl:7
|
||||
qw422016.N().S(`
|
||||
<h1>Index Page</h1>
|
||||
<div>
|
||||
This is our index page's body.
|
||||
</div>
|
||||
`)
|
||||
//line index.qtpl:12
|
||||
|
||||
}
|
||||
|
||||
//line index.qtpl:12
|
||||
|
||||
func (i *Index) WriteBody(qq422016 qtio422016.Writer) {
|
||||
//line index.qtpl:12
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line index.qtpl:12
|
||||
i.StreamBody(qw422016)
|
||||
//line index.qtpl:12
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line index.qtpl:12
|
||||
|
||||
}
|
||||
|
||||
//line index.qtpl:12
|
||||
|
||||
func (i *Index) Body() string {
|
||||
//line index.qtpl:12
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line index.qtpl:12
|
||||
i.WriteBody(qb422016)
|
||||
//line index.qtpl:12
|
||||
qs422016 := string(qb422016.B)
|
||||
//line index.qtpl:12
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line index.qtpl:12
|
||||
return qs422016
|
||||
//line index.qtpl:12
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user