aboutsummaryrefslogtreecommitdiff
path: root/modules/base/template.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-19 14:39:07 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-19 14:39:07 +0800
commit3da325591b5d8578f575f5fad59595f3c5efe4d6 (patch)
tree65d0d4c045311044d2526052dc6b734ff6a56db2 /modules/base/template.go
parent3ceb008e1f50b89a2e0fda8fac939df92642219c (diff)
bug fixed for commits list
Diffstat (limited to 'modules/base/template.go')
-rw-r--r--modules/base/template.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/base/template.go b/modules/base/template.go
index 4517cd47..db79340e 100644
--- a/modules/base/template.go
+++ b/modules/base/template.go
@@ -5,6 +5,7 @@
package base
import (
+ "container/list"
"html/template"
)
@@ -12,6 +13,23 @@ func Str2html(raw string) template.HTML {
return template.HTML(raw)
}
+func Range(l int) []int {
+ return make([]int, l)
+}
+
+func List(l *list.List) chan interface{} {
+ e := l.Front()
+ c := make(chan interface{})
+ go func() {
+ for e != nil {
+ c <- e.Value
+ e = e.Next()
+ }
+ close(c)
+ }()
+ return c
+}
+
var TemplateFuncs template.FuncMap = map[string]interface{}{
"AppName": func() string {
return AppName
@@ -30,4 +48,5 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
"ActionIcon": ActionIcon,
"ActionDesc": ActionDesc,
"DateFormat": DateFormat,
+ "List": List,
}