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
281747ab
authored
2013-03-14 17:57:09 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add BeeTemplateExt
1 parent
512d1156
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
template.go
template.go
View file @
281747a
...
...
@@ -17,13 +17,14 @@ import (
var
(
beegoTplFuncMap
template
.
FuncMap
BeeTemplates
map
[
string
]
*
template
.
Template
BeeTemplateExt
string
BeeTemplateExt
[]
string
)
func
init
()
{
BeeTemplates
=
make
(
map
[
string
]
*
template
.
Template
)
beegoTplFuncMap
=
make
(
template
.
FuncMap
)
BeeTemplateExt
=
"tpl"
BeeTemplateExt
=
make
([]
string
,
0
)
BeeTemplateExt
=
append
(
BeeTemplateExt
,
"tpl"
,
"html"
)
beegoTplFuncMap
[
"markdown"
]
=
MarkDown
beegoTplFuncMap
[
"dateformat"
]
=
DateFormat
beegoTplFuncMap
[
"date"
]
=
Date
...
...
@@ -116,7 +117,14 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
}
else
if
(
f
.
Mode
()
&
os
.
ModeSymlink
)
>
0
{
return
nil
}
else
{
if
strings
.
HasSuffix
(
paths
,
BeeTemplateExt
)
{
hasExt
:=
false
for
_
,
v
:=
range
BeeTemplateExt
{
if
strings
.
HasSuffix
(
paths
,
v
)
{
hasExt
=
true
break
}
}
if
hasExt
{
a
:=
[]
byte
(
paths
)
a
=
a
[
len
([]
byte
(
self
.
root
))
:
]
subdir
:=
path
.
Dir
(
strings
.
TrimLeft
(
string
(
a
),
"/"
))
...
...
@@ -133,8 +141,13 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
return
nil
}
func
SetGlobalTemplateExt
(
ext
string
)
{
BeeTemplateExt
=
ext
func
AddTemplateExt
(
ext
string
)
{
for
_
,
v
:=
range
BeeTemplateExt
{
if
v
==
ext
{
return
}
}
BeeTemplateExt
=
append
(
BeeTemplateExt
,
ext
)
}
func
BuildTemplate
(
dir
string
)
error
{
...
...
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