1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-07 20:17:05 +00:00

create the new FileServer and HandleDir, deprecate the rest APIBuilder/Party static methods and more

relative: https://github.com/kataras/iris/issues/1283 and removing pongo2 from vendor: https://github.com/kataras/iris/issues/1284

Former-commit-id: 3ec57b349f99faca2b8e36d9f7252db0b6ea080d
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-06-21 19:43:25 +03:00
parent 7f9e33cabb
commit d0104defa8
72 changed files with 1585 additions and 1826 deletions

View File

@@ -11,24 +11,25 @@ import (
"strings"
"sync"
"github.com/flosch/pongo2"
"github.com/kataras/iris/context"
"github.com/flosch/pongo2"
)
type (
// Value conversion for pongo2.Value
Value pongo2.Value
// Error conversion for pongo2.Error
Error pongo2.Error
// FilterFunction conversion for pongo2.FilterFunction
FilterFunction func(in *Value, param *Value) (out *Value, err *Error)
// Value type alias for pongo2.Value
Value = pongo2.Value
// Error type alias for pongo2.Error
Error = pongo2.Error
// FilterFunction type alias for pongo2.FilterFunction
FilterFunction = pongo2.FilterFunction
// Parser conversion for pongo2.Parser
Parser pongo2.Parser
// Token conversion for pongo2.Token
Token pongo2.Token
// INodeTag conversion for pongo2.InodeTag
INodeTag pongo2.INodeTag
// Parser type alias for pongo2.Parser
Parser = pongo2.Parser
// Token type alias for pongo2.Token
Token = pongo2.Token
// INodeTag type alias for pongo2.InodeTag
INodeTag = pongo2.INodeTag
// TagParser the function signature of the tag's parser you will have
// to implement in order to create a new tag.
//
@@ -41,44 +42,22 @@ type (
//
// Please see the Parser documentation on how to use the parser.
// See `RegisterTag` for more information about writing a tag as well.
TagParser func(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error)
TagParser = pongo2.TagParser
)
// AsValue converts any given value to a view.Value.
// AsValue converts any given value to a pongo2.Value
// Usually being used within own functions passed to a template
// through a Context or within filter functions.
func AsValue(i interface{}) *Value {
return (*Value)(pongo2.AsValue(i))
}
//
// Example:
// AsValue("my string")
//
// Shortcut for `pongo2.AsValue`.
var AsValue = pongo2.AsValue
// AsSafeValue works like AsValue, but does not apply the 'escape' filter.
func AsSafeValue(i interface{}) *Value {
return (*Value)(pongo2.AsSafeValue(i))
}
// GetValue returns the `Value` as *pongo2.Value type.
// This method was added by balthild at https://github.com/kataras/iris/pull/765
func (value *Value) GetValue() *pongo2.Value {
return (*pongo2.Value)(value)
}
// GetError returns the `Error` as *pongo2.Error type.
// This method was added by balthild at https://github.com/kataras/iris/pull/765
func (error *Error) GetError() *pongo2.Error {
return (*pongo2.Error)(error)
}
// GetParser returns the `Parser` as *pongo2.Parser type.
// This method was added by balthild at https://github.com/kataras/iris/pull/765
func (parser *Parser) GetParser() *pongo2.Parser {
return (*pongo2.Parser)(parser)
}
// GetToken returns the `Token` as *pongo2.Token type.
// This method was added by balthild at https://github.com/kataras/iris/pull/765
func (token *Token) GetToken() *pongo2.Token {
return (*pongo2.Token)(token)
}
// Shortcut for `pongo2.AsSafeValue`.
var AsSafeValue = pongo2.AsSafeValue
type tDjangoAssetLoader struct {
baseDir string
@@ -200,13 +179,8 @@ func (s *DjangoEngine) RegisterFilter(filterName string, filterBody FilterFuncti
return s.registerFilter(filterName, filterBody)
}
func (s *DjangoEngine) registerFilter(filterName string, filterBody FilterFunction) *DjangoEngine {
fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
theOut, theErr := filterBody((*Value)(in), (*Value)(param))
return (*pongo2.Value)(theOut), (*pongo2.Error)(theErr)
})
func (s *DjangoEngine) registerFilter(filterName string, fn FilterFunction) *DjangoEngine {
pongo2.RegisterFilter(filterName, fn)
return s
}
@@ -216,12 +190,7 @@ func (s *DjangoEngine) registerFilter(filterName string, filterBody FilterFuncti
//
// See http://www.florian-schlachter.de/post/pongo2/ for more about
// writing filters and tags.
func (s *DjangoEngine) RegisterTag(tagName string, parserFn TagParser) error {
fn := func(doc *pongo2.Parser, start *pongo2.Token, arguments *pongo2.Parser) (pongo2.INodeTag, *pongo2.Error) {
t, err := parserFn((*Parser)(doc), (*Token)(start), (*Parser)(arguments))
return t, (*pongo2.Error)(err)
}
func (s *DjangoEngine) RegisterTag(tagName string, fn TagParser) error {
return pongo2.RegisterTag(tagName, fn)
}