1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

update dependencies

This commit is contained in:
Gerasimos (Makis) Maropoulos
2025-08-15 23:29:20 +03:00
parent de4f462198
commit a8a3afea22
186 changed files with 694 additions and 689 deletions

View File

@@ -36,11 +36,11 @@ func (s *AceEngine) SetIndent(indent string) *AceEngine {
// Ace("./views", ".ace") or
// Ace(iris.Dir("./views"), ".ace") or
// Ace(embed.FS, ".ace") or Ace(AssetFile(), ".ace") for embedded data.
func Ace(fs interface{}, extension string) *AceEngine {
func Ace(fs any, extension string) *AceEngine {
s := &AceEngine{HTMLEngine: HTML(fs, extension), indent: ""}
s.name = "Ace"
funcs := make(map[string]interface{})
funcs := make(map[string]any)
once := new(sync.Once)

View File

@@ -44,7 +44,7 @@ func WrapBlocks(v *blocks.Blocks) *BlocksEngine {
// Blocks("./views", ".html") or
// Blocks(iris.Dir("./views"), ".html") or
// Blocks(embed.FS, ".html") or Blocks(AssetFile(), ".html") for embedded data.
func Blocks(fs interface{}, extension string) *BlocksEngine {
func Blocks(fs any, extension string) *BlocksEngine {
return WrapBlocks(blocks.New(fs).Extension(extension))
}
@@ -80,13 +80,13 @@ func (s *BlocksEngine) Ext() string {
// by the framework to add template functions like:
// - 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{}) {
// - tr func(lang, key string, args ...any) string
func (s *BlocksEngine) AddFunc(funcName string, funcBody any) {
s.Engine.Funcs(template.FuncMap{funcName: funcBody})
}
// AddLayoutFunc adds a template function for templates that are marked as layouts.
func (s *BlocksEngine) AddLayoutFunc(funcName string, funcBody interface{}) *BlocksEngine {
func (s *BlocksEngine) AddLayoutFunc(funcName string, funcBody any) *BlocksEngine {
s.Engine.LayoutFuncs(template.FuncMap{funcName: funcBody})
return s
}
@@ -115,7 +115,7 @@ func (s *BlocksEngine) Load() error {
}
// ExecuteWriter renders a template on "w".
func (s *BlocksEngine) ExecuteWriter(w io.Writer, tmplName, layoutName string, data interface{}) error {
func (s *BlocksEngine) ExecuteWriter(w io.Writer, tmplName, layoutName string, data any) error {
if layoutName == NoLayout {
layoutName = ""
}

View File

@@ -101,7 +101,7 @@ type DjangoEngine struct {
// filters for pongo2, map[name of the filter] the filter function . The filters are auto register
filters map[string]FilterFunction
// globals share context fields between templates.
globals map[string]interface{}
globals map[string]any
Set *pongo2.TemplateSet
templateCache map[string]*pongo2.Template
}
@@ -118,12 +118,12 @@ var (
// Django("./views", ".html") or
// Django(iris.Dir("./views"), ".html") or
// Django(embed.FS, ".html") or Django(AssetFile(), ".html") for embedded data.
func Django(fs interface{}, extension string) *DjangoEngine {
func Django(fs any, extension string) *DjangoEngine {
s := &DjangoEngine{
fs: getFS(fs),
rootDir: "/",
extension: extension,
globals: make(map[string]interface{}),
globals: make(map[string]any),
filters: make(map[string]FilterFunction),
templateCache: make(map[string]*pongo2.Template),
}
@@ -175,7 +175,7 @@ func (s *DjangoEngine) Reload(developmentMode bool) *DjangoEngine {
// - url func(routeName string, args ...string) string
// - urlpath func(routeName string, args ...string) string
// - render func(fullPartialName string) (template.HTML, error).
func (s *DjangoEngine) AddFunc(funcName string, funcBody interface{}) {
func (s *DjangoEngine) AddFunc(funcName string, funcBody any) {
s.rmu.Lock()
s.globals[funcName] = funcBody
s.rmu.Unlock()
@@ -282,8 +282,8 @@ func (s *DjangoEngine) initSet() { // protected by the caller.
}
}
// getPongoContext returns the pongo2.Context from map[string]interface{} or from pongo2.Context, used internaly
func getPongoContext(templateData interface{}) pongo2.Context {
// getPongoContext returns the pongo2.Context from map[string]any or from pongo2.Context, used internaly
func getPongoContext(templateData any) pongo2.Context {
if templateData == nil {
return nil
}
@@ -294,7 +294,7 @@ func getPongoContext(templateData interface{}) pongo2.Context {
case context.Map:
return pongo2.Context(data)
default:
// if struct, convert it to map[string]interface{}
// if struct, convert it to map[string]any
if structs.IsStruct(data) {
return pongo2.Context(structs.Map(data))
}
@@ -317,7 +317,7 @@ func (s *DjangoEngine) fromCache(relativeName string) *pongo2.Template {
// ExecuteWriter executes a templates and write its results to the w writer
// layout here is useless.
func (s *DjangoEngine) ExecuteWriter(w io.Writer, filename string, _ string, bindingData interface{}) error {
func (s *DjangoEngine) ExecuteWriter(w io.Writer, filename string, _ string, bindingData any) error {
// re-parse the templates if reload is enabled.
if s.reload {
if err := s.Load(); err != nil {

View File

@@ -59,7 +59,7 @@ func asset(fileSystem fs.FS, name string) ([]byte, error) {
return data, nil
}
func getFS(fsOrDir interface{}) fs.FS {
func getFS(fsOrDir any) fs.FS {
return context.ResolveFS(fsOrDir)
}

View File

@@ -44,7 +44,7 @@ var (
// Handlebars("./views", ".html") or
// Handlebars(iris.Dir("./views"), ".html") or
// Handlebars(embed.FS, ".html") or Handlebars(AssetFile(), ".html") for embedded data.
func Handlebars(fs interface{}, extension string) *HandlebarsEngine {
func Handlebars(fs any, extension string) *HandlebarsEngine {
s := &HandlebarsEngine{
fs: getFS(fs),
rootDir: "/",
@@ -54,7 +54,7 @@ func Handlebars(fs interface{}, extension string) *HandlebarsEngine {
}
// register the render helper here
raymond.RegisterHelper("render", func(partial string, binding interface{}) raymond.SafeString {
raymond.RegisterHelper("render", func(partial string, binding any) raymond.SafeString {
contents, err := s.executeTemplateBuf(partial, binding)
if err != nil {
return raymond.SafeString("template with name: " + partial + " couldn't not be found.")
@@ -118,14 +118,14 @@ func (s *HandlebarsEngine) Layout(layoutFile string) *HandlebarsEngine {
// - url func(routeName string, args ...string) string
// - urlpath func(routeName string, args ...string) string
// - render func(fullPartialName string) (raymond.HTML, error).
func (s *HandlebarsEngine) AddFunc(funcName string, funcBody interface{}) {
func (s *HandlebarsEngine) AddFunc(funcName string, funcBody any) {
s.rmu.Lock()
s.funcs[funcName] = funcBody
s.rmu.Unlock()
}
// AddGlobalFunc registers a global template function for all Handlebars view engines.
func (s *HandlebarsEngine) AddGlobalFunc(funcName string, funcBody interface{}) {
func (s *HandlebarsEngine) AddGlobalFunc(funcName string, funcBody any) {
s.rmu.Lock()
raymond.RegisterHelper(funcName, funcBody)
s.rmu.Unlock()
@@ -203,7 +203,7 @@ func (s *HandlebarsEngine) fromCache(relativeName string) *raymond.Template {
return nil
}
func (s *HandlebarsEngine) executeTemplateBuf(name string, binding interface{}) (string, error) {
func (s *HandlebarsEngine) executeTemplateBuf(name string, binding any) (string, error) {
if tmpl := s.fromCache(name); tmpl != nil {
return tmpl.Exec(binding)
}
@@ -211,7 +211,7 @@ func (s *HandlebarsEngine) executeTemplateBuf(name string, binding interface{})
}
// ExecuteWriter executes a template and writes its result to the w writer.
func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error {
func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData any) error {
// re-parse the templates if reload is enabled.
if s.reload {
if err := s.Load(); err != nil {
@@ -231,11 +231,11 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st
if tmpl := s.fromCache(renderFilename); tmpl != nil {
binding := bindingData
if isLayout {
var context map[string]interface{}
if m, is := binding.(map[string]interface{}); is { // handlebars accepts maps,
var context map[string]any
if m, is := binding.(map[string]any); is { // handlebars accepts maps,
context = m
} else {
return fmt.Errorf("please provide a map[string]interface{} type as the binding instead of the %#v", binding)
return fmt.Errorf("please provide a map[string]any type as the binding instead of the %#v", binding)
}
contents, err := s.executeTemplateBuf(filename, binding)
@@ -243,7 +243,7 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st
return err
}
if context == nil {
context = make(map[string]interface{}, 1)
context = make(map[string]any, 1)
}
// I'm implemented the {{ yield . }} as with the rest of template engines, so this is not inneed for iris, but the user can do that manually if want
// there is no performance cost: raymond.RegisterPartialTemplate(name, tmpl)

View File

@@ -65,7 +65,7 @@ var (
// HTML(iris.Dir("./views"), ".html") or
// HTML(embed.FS, ".html") or HTML(AssetFile(), ".html") for embedded data or
// HTML("","").ParseTemplate("hello", `[]byte("hello {{.Name}}")`, nil) for custom template parsing only.
func HTML(dirOrFS interface{}, extension string) *HTMLEngine {
func HTML(dirOrFS any, extension string) *HTMLEngine {
s := &HTMLEngine{
name: "HTML",
fs: getFS(dirOrFS),
@@ -76,12 +76,12 @@ func HTML(dirOrFS interface{}, extension string) *HTMLEngine {
right: "}}",
layout: "",
layoutFuncs: template.FuncMap{
"yield": func(binding interface{}) template.HTML {
"yield": func(binding any) template.HTML {
return template.HTML("")
},
},
funcs: make(template.FuncMap),
bufPool: &sync.Pool{New: func() interface{} {
bufPool: &sync.Pool{New: func() any {
return new(bytes.Buffer)
}},
}
@@ -105,7 +105,7 @@ func (s *HTMLEngine) RootDir(root string) *HTMLEngine {
}
// FS change templates DIR
func (s *HTMLEngine) FS(dirOrFS interface{}) *HTMLEngine {
func (s *HTMLEngine) FS(dirOrFS any) *HTMLEngine {
s.fs = getFS(dirOrFS)
return s
}
@@ -191,7 +191,7 @@ func (s *HTMLEngine) Layout(layoutFile string) *HTMLEngine {
// - partial func(partialName string) (template.HTML, error)
// - partial_r func(partialName string) (template.HTML, error)
// - render func(fullPartialName string) (template.HTML, error).
func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody interface{}) *HTMLEngine {
func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody any) *HTMLEngine {
s.rmu.Lock()
s.layoutFuncs[funcName] = funcBody
s.rmu.Unlock()
@@ -203,8 +203,8 @@ func (s *HTMLEngine) AddLayoutFunc(funcName string, funcBody interface{}) *HTMLE
// - url func(routeName string, args ...string) string
// - 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{}) {
// - tr func(lang, key string, args ...any) string
func (s *HTMLEngine) AddFunc(funcName string, funcBody any) {
s.rmu.Lock()
s.funcs[funcName] = funcBody
s.rmu.Unlock()
@@ -369,7 +369,7 @@ func (s *HTMLEngine) initRootTmpl() { // protected by the caller.
}
}
func (s *HTMLEngine) executeTemplateBuf(name string, binding interface{}) (string, error) {
func (s *HTMLEngine) executeTemplateBuf(name string, binding any) (string, error) {
buf := s.bufPool.Get().(*bytes.Buffer)
buf.Reset()
@@ -381,7 +381,7 @@ func (s *HTMLEngine) executeTemplateBuf(name string, binding interface{}) (strin
func (s *HTMLEngine) getBuiltinRuntimeLayoutFuncs(name string) template.FuncMap {
funcs := template.FuncMap{
"yield": func(binding interface{}) (template.HTML, error) {
"yield": func(binding any) (template.HTML, error) {
result, err := s.executeTemplateBuf(name, binding)
// Return safe HTML here since we are rendering our own template.
return template.HTML(result), err
@@ -393,7 +393,7 @@ func (s *HTMLEngine) getBuiltinRuntimeLayoutFuncs(name string) template.FuncMap
func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
funcs := template.FuncMap{
"part": func(partName string, binding interface{}) (template.HTML, error) {
"part": func(partName string, binding any) (template.HTML, error) {
nameTemp := strings.ReplaceAll(name, s.extension, "")
fullPartName := fmt.Sprintf("%s-%s", nameTemp, partName)
result, err := s.executeTemplateBuf(fullPartName, binding)
@@ -405,7 +405,7 @@ func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
"current": func() (string, error) {
return name, nil
},
"partial": func(partialName string, binding interface{}) (template.HTML, error) {
"partial": func(partialName string, binding any) (template.HTML, error) {
fullPartialName := fmt.Sprintf("%s-%s", partialName, name)
if s.Templates.Lookup(fullPartialName) != nil {
result, err := s.executeTemplateBuf(fullPartialName, binding)
@@ -417,7 +417,7 @@ func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
// it would be easier for adding pages' style/script inline
// for example when using partial_r '.script' in layout.html
// templates/users/index.html would load templates/users/index.script.html
"partial_r": func(partialName string, binding interface{}) (template.HTML, error) {
"partial_r": func(partialName string, binding any) (template.HTML, error) {
ext := filepath.Ext(name)
root := name[:len(name)-len(ext)]
fullPartialName := fmt.Sprintf("%s%s%s", root, partialName, ext)
@@ -427,7 +427,7 @@ func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
}
return "", nil
},
"render": func(fullPartialName string, binding interface{}) (template.HTML, error) {
"render": func(fullPartialName string, binding any) (template.HTML, error) {
result, err := s.executeTemplateBuf(fullPartialName, binding)
return template.HTML(result), err
},
@@ -437,7 +437,7 @@ func (s *HTMLEngine) getBuiltinFuncs(name string) template.FuncMap {
}
// ExecuteWriter executes a template and writes its result to the w writer.
func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bindingData interface{}) error {
func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bindingData any) error {
// re-parse the templates if reload is enabled.
if s.reload {
s.rmu.Lock()

View File

@@ -35,7 +35,7 @@ type JetEngine struct {
// Note that global vars and functions are set in a single spot on the jet parser.
// If AddFunc or AddVar called before `Load` then these will be set here to be used via `Load` and clear.
vars map[string]interface{}
vars map[string]any
jetDataContextKey string
}
@@ -60,7 +60,7 @@ var jetExtensions = [...]string{
// Jet("./views", ".jet") or
// Jet(iris.Dir("./views"), ".jet") or
// Jet(embed.FS, ".jet") or Jet(AssetFile(), ".jet") for embedded data.
func Jet(dirOrFS interface{}, extension string) *JetEngine {
func Jet(dirOrFS any, extension string) *JetEngine {
extOK := false
for _, ext := range jetExtensions {
if ext == extension {
@@ -131,10 +131,10 @@ func (s *JetEngine) Delims(left, right string) *JetEngine {
type JetArguments = jet.Arguments
// AddFunc should adds a global function to the jet template set.
func (s *JetEngine) AddFunc(funcName string, funcBody interface{}) {
func (s *JetEngine) AddFunc(funcName string, funcBody any) {
// if something like "urlpath" is registered.
if generalFunc, ok := funcBody.(func(string, ...interface{}) string); ok {
// jet, unlike others does not accept a func(string, ...interface{}) string,
if generalFunc, ok := funcBody.(func(string, ...any) string); ok {
// jet, unlike others does not accept a func(string, ...any) string,
// instead it wants:
// func(JetArguments) reflect.Value.
@@ -153,7 +153,7 @@ func (s *JetEngine) AddFunc(funcName string, funcBody interface{}) {
// if has variadic.
variadicN := n - 1
variadicInputs := make([]interface{}, variadicN) // except the first one.
variadicInputs := make([]any, variadicN) // except the first one.
for i := 0; i < variadicN; i++ {
variadicInputs[i] = args.Get(i + 1).Interface()
@@ -178,12 +178,12 @@ func (s *JetEngine) AddFunc(funcName string, funcBody interface{}) {
}
// AddVar adds a global variable to the jet template set.
func (s *JetEngine) AddVar(key string, value interface{}) {
func (s *JetEngine) AddVar(key string, value any) {
if s.Set != nil {
s.Set.AddGlobal(key, value)
} else {
if s.vars == nil {
s.vars = make(map[string]interface{})
s.vars = make(map[string]any)
}
s.vars[key] = value
}
@@ -334,7 +334,7 @@ func (s *JetEngine) AddRuntimeVars(ctx *context.Context, vars JetRuntimeVars) {
}
// ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
func (s *JetEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error {
func (s *JetEngine) ExecuteWriter(w io.Writer, filename string, layout string, bindingData any) error {
tmpl, err := s.Set.GetTemplate(filename)
if err != nil {
return err
@@ -391,7 +391,7 @@ func (s *JetEngine) ExecuteWriter(w io.Writer, filename string, layout string, b
/* fixed on jet v4.0.0, so no need of this:
if m, ok := bindingData.(context.Map); ok {
var jetData interface{}
var jetData any
for k, v := range m {
if k == s.jetDataContextKey {
jetData = v

View File

@@ -24,7 +24,7 @@ import (
// https://github.com/kataras/iris/tree/main/_examples/view/template_pug_1
// https://github.com/kataras/iris/tree/main/_examples/view/template_pug_2
// https://github.com/kataras/iris/tree/main/_examples/view/template_pug_3
func Pug(fs interface{}, extension string) *HTMLEngine {
func Pug(fs any, extension string) *HTMLEngine {
s := HTML(fs, extension)
s.name = "Pug"
s.middleware = func(name string, text []byte) (contents string, err error) {

View File

@@ -58,7 +58,7 @@ func (v *View) ensureTemplateName(s string) string {
}
// ExecuteWriter calls the correct view Engine's ExecuteWriter func
func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error {
func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindingData any) error {
filename = v.ensureTemplateName(filename)
layout = v.ensureTemplateName(layout)
@@ -67,7 +67,7 @@ func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindin
// AddFunc adds a function to all registered engines.
// Each template engine that supports functions has its own AddFunc too.
func (v *View) AddFunc(funcName string, funcBody interface{}) {
func (v *View) AddFunc(funcName string, funcBody any) {
if !v.Registered() {
return
}