Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
fb1439df
Commit
fb1439df
authored
Sep 26, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #224 from smithfox/patch-1
fix #217
parents
d393c329
bed0fe22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
template.go
template.go
+21
-6
No files found.
template.go
View file @
fb1439df
...
@@ -160,6 +160,19 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
...
@@ -160,6 +160,19 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
t
=
template
.
New
(
file
)
.
Delims
(
TemplateLeft
,
TemplateRight
)
.
Funcs
(
beegoTplFuncMap
)
t
=
template
.
New
(
file
)
.
Delims
(
TemplateLeft
,
TemplateRight
)
.
Funcs
(
beegoTplFuncMap
)
var
submods
[][]
string
var
submods
[][]
string
t
,
submods
,
err
=
getTplDeep
(
root
,
file
,
t
)
t
,
submods
,
err
=
getTplDeep
(
root
,
file
,
t
)
if
err
!=
nil
{
return
nil
,
err
}
t
,
err
=
_getTemplate
(
t
,
root
,
submods
,
others
...
)
if
err
!=
nil
{
return
nil
,
err
}
return
}
func
_getTemplate
(
t0
*
template
.
Template
,
root
string
,
submods
[][]
string
,
others
...
string
)
(
t
*
template
.
Template
,
err
error
)
{
t
=
t0
for
_
,
m
:=
range
submods
{
for
_
,
m
:=
range
submods
{
if
len
(
m
)
==
2
{
if
len
(
m
)
==
2
{
templ
:=
t
.
Lookup
(
m
[
1
])
templ
:=
t
.
Lookup
(
m
[
1
])
...
@@ -169,9 +182,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
...
@@ -169,9 +182,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
//first check filename
//first check filename
for
_
,
otherfile
:=
range
others
{
for
_
,
otherfile
:=
range
others
{
if
otherfile
==
m
[
1
]
{
if
otherfile
==
m
[
1
]
{
t
,
_
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
var
submods1
[][]
string
t
,
submods1
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
Trace
(
"template parse file err:"
,
err
)
Trace
(
"template parse file err:"
,
err
)
}
else
if
submods1
!=
nil
&&
len
(
submods1
)
>
0
{
t
,
err
=
_getTemplate
(
t
,
root
,
submods1
,
others
...
)
}
}
break
break
}
}
...
@@ -187,9 +203,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
...
@@ -187,9 +203,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
allsub
:=
reg
.
FindAllStringSubmatch
(
string
(
data
),
-
1
)
allsub
:=
reg
.
FindAllStringSubmatch
(
string
(
data
),
-
1
)
for
_
,
sub
:=
range
allsub
{
for
_
,
sub
:=
range
allsub
{
if
len
(
sub
)
==
2
&&
sub
[
1
]
==
m
[
1
]
{
if
len
(
sub
)
==
2
&&
sub
[
1
]
==
m
[
1
]
{
t
,
_
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
var
submods1
[][]
string
t
,
submods1
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
Trace
(
"template parse file err:"
,
err
)
Trace
(
"template parse file err:"
,
err
)
}
else
if
submods1
!=
nil
&&
len
(
submods1
)
>
0
{
t
,
err
=
_getTemplate
(
t
,
root
,
submods1
,
others
...
)
}
}
break
break
}
}
...
@@ -198,9 +217,5 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
...
@@ -198,9 +217,5 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
}
}
}
}
if
err
!=
nil
{
return
nil
,
err
}
return
return
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment