mirror of
https://github.com/kataras/iris.git
synced 2025-03-13 21:36:28 +01:00
Resolve {%extends%} & {%include%} tags problem
Former-commit-id: 2f52b831993832cc8c7dd4e7aff55848b3266e0a
This commit is contained in:
parent
a2af84336f
commit
8b0c381808
|
@ -1,10 +1,12 @@
|
|||
package view
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
stdPath "path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -22,6 +24,35 @@ type (
|
|||
FilterFunction func(in *Value, param *Value) (out *Value, err *Error)
|
||||
)
|
||||
|
||||
type tDjangoAssetLoader struct {
|
||||
baseDir string
|
||||
assetGet func(name string) ([]byte, error)
|
||||
}
|
||||
|
||||
// Abs calculates the path to a given template. Whenever a path must be resolved
|
||||
// due to an import from another template, the base equals the parent template's path.
|
||||
func (dal *tDjangoAssetLoader) Abs(base, name string) string {
|
||||
if stdPath.IsAbs(name) {
|
||||
return name
|
||||
}
|
||||
|
||||
return stdPath.Join(dal.baseDir, name)
|
||||
}
|
||||
|
||||
// Get returns an io.Reader where the template's content can be read from.
|
||||
func (dal *tDjangoAssetLoader) Get(path string) (io.Reader, error) {
|
||||
if stdPath.IsAbs(path) {
|
||||
path = path[1:]
|
||||
}
|
||||
|
||||
res, err := dal.assetGet(path)
|
||||
if err {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return bytes.NewBuffer(res), nil
|
||||
}
|
||||
|
||||
// DjangoEngine contains the amber view engine structure.
|
||||
type DjangoEngine struct {
|
||||
// files configuration
|
||||
|
|
Loading…
Reference in New Issue
Block a user