-
Notifications
You must be signed in to change notification settings - Fork 222
/
sqltemplate.go
65 lines (58 loc) · 1.9 KB
/
sqltemplate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package xorm
import (
"html/template"
"os"
"github.com/CloudyKit/jet"
"gopkg.in/flosch/pongo2.v3"
)
type FuncMap map[string]interface{}
type SqlTemplate interface {
WalkFunc(path string, info os.FileInfo, err error) error
paresSqlTemplate(filename string, filepath string) error
ReadTemplate(filepath string) ([]byte, error)
Execute(key string, args ...interface{}) (string, error)
RootDir() string
Extension() string
SetSqlTemplateCipher(cipher Cipher)
LoadSqlTemplate(filepath string) error
BatchLoadSqlTemplate(filepathSlice []string) error
ReloadSqlTemplate(filepath string) error
BatchReloadSqlTemplate(filepathSlice []string) error
AddSqlTemplate(key string, sqlTemplateStr string) error
UpdateSqlTemplate(key string, sqlTemplateStr string) error
RemoveSqlTemplate(key string)
BatchAddSqlTemplate(key string, sqlTemplateStrMap map[string]string) error
BatchUpdateSqlTemplate(key string, sqlTemplateStrMap map[string]string) error
BatchRemoveSqlTemplate(key []string)
SetFuncs(key string, funcMap FuncMap)
}
func Pongo2(directory, extension string) *Pongo2Template {
template := make(map[string]*pongo2.Template, 100)
funcs := make(map[string]FuncMap, 20)
return &Pongo2Template{
SqlTemplateRootDir: directory,
extension: extension,
Template: template,
Funcs: funcs,
}
}
func Default(directory, extension string) *HTMLTemplate {
template := make(map[string]*template.Template, 100)
funcs := make(map[string]FuncMap, 20)
return &HTMLTemplate{
SqlTemplateRootDir: directory,
extension: extension,
Template: template,
Funcs: funcs,
}
}
func Jet(directory, extension string) *JetTemplate {
template := make(map[string]*jet.Template, 100)
funcs := make(map[string]FuncMap, 20)
return &JetTemplate{
SqlTemplateRootDir: directory,
extension: extension,
Template: template,
Funcs: funcs,
}
}