Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
fb1439df
authored
2013-09-26 06:09:03 -0700
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #224 from smithfox/patch-1
fix #217
2 parents
d393c329
bed0fe22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
template.go
template.go
View file @
fb1439d
...
...
@@ -160,6 +160,19 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
t
=
template
.
New
(
file
)
.
Delims
(
TemplateLeft
,
TemplateRight
)
.
Funcs
(
beegoTplFuncMap
)
var
submods
[][]
string
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
{
if
len
(
m
)
==
2
{
templ
:=
t
.
Lookup
(
m
[
1
])
...
...
@@ -169,9 +182,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
//first check filename
for
_
,
otherfile
:=
range
others
{
if
otherfile
==
m
[
1
]
{
t
,
_
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
var
submods1
[][]
string
t
,
submods1
,
err
=
getTplDeep
(
root
,
otherfile
,
t
)
if
err
!=
nil
{
Trace
(
"template parse file err:"
,
err
)
}
else
if
submods1
!=
nil
&&
len
(
submods1
)
>
0
{
t
,
err
=
_getTemplate
(
t
,
root
,
submods1
,
others
...
)
}
break
}
...
...
@@ -187,9 +203,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
allsub
:=
reg
.
FindAllStringSubmatch
(
string
(
data
),
-
1
)
for
_
,
sub
:=
range
allsub
{
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
{
Trace
(
"template parse file err:"
,
err
)
}
else
if
submods1
!=
nil
&&
len
(
submods1
)
>
0
{
t
,
err
=
_getTemplate
(
t
,
root
,
submods1
,
others
...
)
}
break
}
...
...
@@ -198,9 +217,5 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
}
}
if
err
!=
nil
{
return
nil
,
err
}
return
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment