mirror of
https://gitee.com/johng/gf
synced 2026-07-05 21:32:17 +08:00
improve function SetPath/AddPath for package gview
This commit is contained in:
@ -95,8 +95,13 @@ func (view *View) SetConfigWithMap(m map[string]interface{}) error {
|
||||
// SetPath sets the template directory path for template file search.
|
||||
// The parameter <path> can be absolute or relative path, but absolute path is suggested.
|
||||
func (view *View) SetPath(path string) error {
|
||||
isDir := false
|
||||
realPath := ""
|
||||
var (
|
||||
isDir = false
|
||||
realPath = ""
|
||||
)
|
||||
if path == "" {
|
||||
path = "."
|
||||
}
|
||||
if file := gres.Get(path); file != nil {
|
||||
realPath = path
|
||||
isDir = file.FileInfo().IsDir()
|
||||
@ -147,8 +152,13 @@ func (view *View) SetPath(path string) error {
|
||||
|
||||
// AddPath adds a absolute or relative path to the search paths.
|
||||
func (view *View) AddPath(path string) error {
|
||||
isDir := false
|
||||
realPath := ""
|
||||
var (
|
||||
isDir = false
|
||||
realPath = ""
|
||||
)
|
||||
if path == "" {
|
||||
path = "."
|
||||
}
|
||||
if file := gres.Get(path); file != nil {
|
||||
realPath = path
|
||||
isDir = file.FileInfo().IsDir()
|
||||
|
||||
Reference in New Issue
Block a user