mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:40:55 +00:00
Merge pull request #2496 from eyalpost/develop
Don't panic during AddViewPath if adding the same path twice
This commit is contained in:
commit
206f736819
@ -72,7 +72,7 @@ func ExecuteViewPathTemplate(wr io.Writer, name string, viewPath string, data in
|
|||||||
}
|
}
|
||||||
panic("can't find templatefile in the path:" + viewPath + "/" + name)
|
panic("can't find templatefile in the path:" + viewPath + "/" + name)
|
||||||
}
|
}
|
||||||
panic("Uknown view path:" + viewPath)
|
panic("Unknown view path:" + viewPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -165,6 +165,9 @@ func AddTemplateExt(ext string) {
|
|||||||
//will panic if called after beego.Run()
|
//will panic if called after beego.Run()
|
||||||
func AddViewPath(viewPath string) error {
|
func AddViewPath(viewPath string) error {
|
||||||
if beeViewPathTemplateLocked {
|
if beeViewPathTemplateLocked {
|
||||||
|
if _, exist := beeViewPathTemplates[viewPath]; exist {
|
||||||
|
return nil //Ignore if viewpath already exists
|
||||||
|
}
|
||||||
panic("Can not add new view paths after beego.Run()")
|
panic("Can not add new view paths after beego.Run()")
|
||||||
}
|
}
|
||||||
beeViewPathTemplates[viewPath] = make(map[string]*template.Template)
|
beeViewPathTemplates[viewPath] = make(map[string]*template.Template)
|
||||||
|
Loading…
Reference in New Issue
Block a user