mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
Full support of the http.FileSystem on all view engines as requested at #1575
Also, the HandleDir accepts both string and http.FileSystem (interface{}) (like the view's fs)
This commit is contained in:
@@ -39,8 +39,28 @@ func WrapBlocks(v *blocks.Blocks) *BlocksEngine {
|
||||
// The given "extension" MUST begin with a dot.
|
||||
//
|
||||
// See `WrapBlocks` package-level function too.
|
||||
func Blocks(directory, extension string) *BlocksEngine {
|
||||
return WrapBlocks(blocks.New(directory).Extension(extension))
|
||||
//
|
||||
// Usage:
|
||||
// Blocks("./views", ".html") or
|
||||
// Blocks(iris.Dir("./views"), ".html") or
|
||||
// Blocks(AssetFile(), ".html") for embedded data.
|
||||
func Blocks(fs interface{}, extension string) *BlocksEngine {
|
||||
return WrapBlocks(blocks.New(fs).Extension(extension))
|
||||
}
|
||||
|
||||
// RootDir sets the directory to use as the root one inside the provided File System.
|
||||
func (s *BlocksEngine) RootDir(root string) *BlocksEngine {
|
||||
s.Engine.RootDir(root)
|
||||
return s
|
||||
}
|
||||
|
||||
// LayoutDir sets a custom layouts directory,
|
||||
// always relative to the "rootDir" one.
|
||||
// Layouts are recognised by their prefix names.
|
||||
// Defaults to "layouts".
|
||||
func (s *BlocksEngine) LayoutDir(relToDirLayoutDir string) *BlocksEngine {
|
||||
s.Engine.LayoutDir(relToDirLayoutDir)
|
||||
return s
|
||||
}
|
||||
|
||||
// Ext returns empty ext as this template engine
|
||||
@@ -66,18 +86,6 @@ func (s *BlocksEngine) AddLayoutFunc(funcName string, funcBody interface{}) *Blo
|
||||
return s
|
||||
}
|
||||
|
||||
// Binary sets the function which reads contents based on a filename
|
||||
// and a function that returns all the filenames.
|
||||
// These functions are used to parse the corresponding files into templates.
|
||||
// You do not need to set them when the given "rootDir" was a system directory.
|
||||
// It's mostly useful when the application contains embedded template files,
|
||||
// e.g. pass go-bindata's `Asset` and `AssetNames` functions
|
||||
// to load templates from go-bindata generated content.
|
||||
func (s *BlocksEngine) Binary(asset blocks.AssetFunc, assetNames blocks.AssetNamesFunc) *BlocksEngine {
|
||||
s.Engine.Assets(asset, assetNames)
|
||||
return s
|
||||
}
|
||||
|
||||
// Layout sets the default layout which inside should use
|
||||
// the {{ template "content" . }} to render the main template.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user