mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
various improvements and new 'UseOnce' method - read HISTORY.md
This commit is contained in:
@@ -17,25 +17,7 @@ Parse using embedded assets, Layouts and Party-specific layout, Template Funcs,
|
||||
| 7 | Jet | [CloudyKit/jet](https://github.com/CloudyKit/jet) |
|
||||
| 8 | Ace | [yosssi/ace](https://github.com/yosssi/ace) |
|
||||
|
||||
## Examples
|
||||
|
||||
- [Overview](https://github.com/kataras/iris/blob/master/_examples/view/overview/main.go)
|
||||
- [Hi](https://github.com/kataras/iris/blob/master/_examples/view/template_html_0/main.go)
|
||||
- [A simple Layout](https://github.com/kataras/iris/blob/master/_examples/view/template_html_1/main.go)
|
||||
- [Layouts: `yield` and `render` tmpl funcs](https://github.com/kataras/iris/blob/master/_examples/view/template_html_2/main.go)
|
||||
- [The `urlpath` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_3/main.go)
|
||||
- [The `url` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_4/main.go)
|
||||
- [Inject Data Between Handlers](https://github.com/kataras/iris/blob/master/_examples/view/context-view-data/main.go)
|
||||
- [Embedding Templates Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/view/embedding-templates-into-app/main.go)
|
||||
- [Blocks](https://github.com/kataras/iris/blob/master/_examples/view/template_blocks_0)
|
||||
- [Blocks Embedded](https://github.com/kataras/iris/blob/master/_examples/view/template_blocks_1_embedded)
|
||||
- [Greeting with Pug (Jade)`](view/template_pug_0)
|
||||
- [Pug (Jade) Actions`](https://github.com/kataras/iris/blob/master/_examples/view/template_pug_1)
|
||||
- [Pug (Jade) Includes`](https://github.com/kataras/iris/blob/master/_examples/view/template_pug_2)
|
||||
- [Pug (Jade) Extends`](https://github.com/kataras/iris/blob/master/_examples/view/template_pug_3)
|
||||
- [Jet](https://github.com/kataras/iris/blob/master/_examples/view/template_jet_0)
|
||||
- [Jet Embedded](https://github.com/kataras/iris/blob/master/_examples/view/template_jet_1_embedded)
|
||||
- [Ace](https://github.com/kataras/iris/blob/master/_examples/view/template_ace_0)
|
||||
[List of Examples](https://github.com/kataras/iris/tree/master/_examples/view).
|
||||
|
||||
You can serve [quicktemplate](https://github.com/valyala/quicktemplate) files too, simply by using the `Context.ResponseWriter`, take a look at the [iris/_examples/view/quicktemplate](https://github.com/kataras/iris/tree/master/_examples/view/quicktemplate) example.
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@ type AmberEngine struct {
|
||||
templateCache map[string]*template.Template
|
||||
}
|
||||
|
||||
var _ Engine = (*AmberEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*AmberEngine)(nil)
|
||||
_ EngineFuncer = (*AmberEngine)(nil)
|
||||
)
|
||||
|
||||
// Amber creates and returns a new amber view engine.
|
||||
// The given "extension" MUST begin with a dot.
|
||||
|
||||
@@ -24,7 +24,10 @@ type BlocksEngine struct {
|
||||
Engine *blocks.Blocks
|
||||
}
|
||||
|
||||
var _ Engine = (*BlocksEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*BlocksEngine)(nil)
|
||||
_ EngineFuncer = (*BlocksEngine)(nil)
|
||||
)
|
||||
|
||||
// WrapBlocks wraps an initialized blocks engine and returns its Iris adapter.
|
||||
// See `Blocks` package-level function too.
|
||||
@@ -53,9 +56,8 @@ func (s *BlocksEngine) Ext() string {
|
||||
// - url func(routeName string, args ...string) string
|
||||
// - urlpath func(routeName string, args ...string) string
|
||||
// - tr func(lang, key string, args ...interface{}) string
|
||||
func (s *BlocksEngine) AddFunc(funcName string, funcBody interface{}) *BlocksEngine {
|
||||
func (s *BlocksEngine) AddFunc(funcName string, funcBody interface{}) {
|
||||
s.Engine.Funcs(template.FuncMap{funcName: funcBody})
|
||||
return s
|
||||
}
|
||||
|
||||
// AddLayoutFunc adds a template function for templates that are marked as layouts.
|
||||
|
||||
@@ -106,7 +106,10 @@ type DjangoEngine struct {
|
||||
templateCache map[string]*pongo2.Template
|
||||
}
|
||||
|
||||
var _ Engine = (*DjangoEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*DjangoEngine)(nil)
|
||||
_ EngineFuncer = (*DjangoEngine)(nil)
|
||||
)
|
||||
|
||||
// Django creates and returns a new django view engine.
|
||||
// The given "extension" MUST begin with a dot.
|
||||
|
||||
@@ -27,7 +27,10 @@ type HandlebarsEngine struct {
|
||||
templateCache map[string]*raymond.Template
|
||||
}
|
||||
|
||||
var _ Engine = (*HandlebarsEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*HandlebarsEngine)(nil)
|
||||
_ EngineFuncer = (*HandlebarsEngine)(nil)
|
||||
)
|
||||
|
||||
// Handlebars creates and returns a new handlebars view engine.
|
||||
// The given "extension" MUST begin with a dot.
|
||||
|
||||
@@ -35,7 +35,10 @@ type HTMLEngine struct {
|
||||
//
|
||||
}
|
||||
|
||||
var _ Engine = (*HTMLEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*HTMLEngine)(nil)
|
||||
_ EngineFuncer = (*HTMLEngine)(nil)
|
||||
)
|
||||
|
||||
var emptyFuncs = template.FuncMap{
|
||||
"yield": func(binding interface{}) (string, error) {
|
||||
@@ -175,12 +178,10 @@ func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody interface{}) *HTMLE
|
||||
// - urlpath func(routeName string, args ...string) string
|
||||
// - render func(fullPartialName string) (template.HTML, error).
|
||||
// - tr func(lang, key string, args ...interface{}) string
|
||||
func (s *HTMLEngine) AddFunc(funcName string, funcBody interface{}) *HTMLEngine {
|
||||
func (s *HTMLEngine) AddFunc(funcName string, funcBody interface{}) {
|
||||
s.rmu.Lock()
|
||||
s.funcs[funcName] = funcBody
|
||||
s.rmu.Unlock()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
// SetFuncs overrides the template funcs with the given "funcMap".
|
||||
|
||||
@@ -36,7 +36,10 @@ type JetEngine struct {
|
||||
jetDataContextKey string
|
||||
}
|
||||
|
||||
var _ Engine = (*JetEngine)(nil)
|
||||
var (
|
||||
_ Engine = (*JetEngine)(nil)
|
||||
_ EngineFuncer = (*JetEngine)(nil)
|
||||
)
|
||||
|
||||
// jet library does not export or give us any option to modify them via Set
|
||||
// (unless we parse the files by ourselves but this is not a smart choice).
|
||||
|
||||
Reference in New Issue
Block a user