Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a572ac3

Browse filesBrowse files
authored
Merge pull request revel#1228 from notzippy/pre-release
Updated key go.template.caseinsensitive
2 parents a756e00 + a3d6493 commit a572ac3
Copy full SHA for a572ac3

File tree

2 files changed

+18
-24
lines changed
Filter options

2 files changed

+18
-24
lines changed

‎revel.go

Copy file name to clipboardExpand all lines: revel.go
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ var (
9292
// Cookie flags
9393
CookieSecure bool
9494

95-
// Delimiters to use when rendering templates
96-
TemplateDelims string
97-
9895
// Revel request access log, not exposed from package.
9996
// However output settings can be controlled from app.conf
10097

@@ -195,7 +192,6 @@ func Init(mode, importPath, srcPath string) {
195192
CookiePrefix = Config.StringDefault("cookie.prefix", "REVEL")
196193
CookieDomain = Config.StringDefault("cookie.domain", "")
197194
CookieSecure = Config.BoolDefault("cookie.secure", HTTPSsl)
198-
TemplateDelims = Config.StringDefault("template.delimiters", "")
199195
if secretStr := Config.StringDefault("app.secret", ""); secretStr != "" {
200196
SetSecretKey([]byte(secretStr))
201197
}
@@ -270,7 +266,7 @@ func findSrcPaths(importPath string) (revelSourcePath, appSourcePath string) {
270266

271267
appPkg, err := build.Import(importPath, "", build.FindOnly)
272268
if err != nil {
273-
RevelLog.Panic("Failed to import"+importPath+"with error:", "error", err)
269+
RevelLog.Panic("Failed to import "+importPath+" with error:", "error", err)
274270
}
275271

276272
revelPkg, err := build.Import(RevelImportPath, "", build.FindOnly)

‎template_adapter_go.go

Copy file name to clipboardExpand all lines: template_adapter_go.go
+17-19Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
const GO_TEMPLATE = "go"
1111

12-
1312
// Adapter for Go Templates.
1413
type GoTemplate struct {
1514
*template.Template
@@ -23,35 +22,34 @@ func (gotmpl GoTemplate) Render(wr io.Writer, arg interface{}) error {
2322
}
2423

2524
type GoEngine struct {
26-
loader *TemplateLoader
27-
templateSet *template.Template
28-
// TemplatesBylowerName is a map from lower case template name to the real template.
29-
templatesBylowerName map[string]*GoTemplate
30-
splitDelims []string
31-
CaseInsensitiveMode bool
25+
loader *TemplateLoader
26+
templateSet *template.Template
27+
templatesByName map[string]*GoTemplate
28+
splitDelims []string
29+
CaseInsensitive bool
3230
}
3331

3432
func (i *GoEngine) ConvertPath(path string) string {
35-
if i.CaseInsensitiveMode {
33+
if i.CaseInsensitive {
3634
return strings.ToLower(path)
3735
}
3836
return path
3937
}
4038

41-
func (i *GoEngine) Handles(templateView *TemplateView) bool{
39+
func (i *GoEngine) Handles(templateView *TemplateView) bool {
4240
return EngineHandles(i, templateView)
4341
}
4442

4543
func (engine *GoEngine) ParseAndAdd(baseTemplate *TemplateView) error {
4644
// If alternate delimiters set for the project, change them for this set
47-
if engine.splitDelims != nil && strings.Index(baseTemplate.Location(), ViewsPath)>-1 {
45+
if engine.splitDelims != nil && strings.Index(baseTemplate.Location(), ViewsPath) > -1 {
4846
engine.templateSet.Delims(engine.splitDelims[0], engine.splitDelims[1])
4947
} else {
5048
// Reset to default otherwise
5149
engine.templateSet.Delims("", "")
5250
}
5351
templateSource := string(baseTemplate.FileBytes)
54-
lowerTemplateName := engine.ConvertPath(baseTemplate.TemplateName)
52+
templateName := engine.ConvertPath(baseTemplate.TemplateName)
5553
tpl, err := engine.templateSet.New(baseTemplate.TemplateName).Parse(templateSource)
5654
if nil != err {
5755
_, line, description := ParseTemplateError(err)
@@ -63,13 +61,13 @@ func (engine *GoEngine) ParseAndAdd(baseTemplate *TemplateView) error {
6361
SourceLines: strings.Split(templateSource, "\n"),
6462
}
6563
}
66-
engine.templatesBylowerName[lowerTemplateName] = &GoTemplate{Template: tpl, engine: engine, TemplateView: baseTemplate}
64+
engine.templatesByName[templateName] = &GoTemplate{Template: tpl, engine: engine, TemplateView: baseTemplate}
6765
return nil
6866
}
6967

7068
func (engine *GoEngine) Lookup(templateName string) Template {
7169
// Case-insensitive matching of template file name
72-
if tpl, found := engine.templatesBylowerName[engine.ConvertPath(templateName)]; found {
70+
if tpl, found := engine.templatesByName[engine.ConvertPath(templateName)]; found {
7371
return tpl
7472
}
7573
return nil
@@ -80,10 +78,10 @@ func (engine *GoEngine) Name() string {
8078
func (engine *GoEngine) Event(action int, i interface{}) {
8179
if action == TEMPLATE_REFRESH_REQUESTED {
8280
// At this point all the templates have been passed into the
83-
engine.templatesBylowerName = map[string]*GoTemplate{}
81+
engine.templatesByName = map[string]*GoTemplate{}
8482
engine.templateSet = template.New("__root__").Funcs(TemplateFuncs)
8583
// Check to see what should be used for case sensitivity
86-
engine.CaseInsensitiveMode = Config.StringDefault("go.template.path", "lower") != "case"
84+
engine.CaseInsensitive = Config.BoolDefault("go.template.caseinsensitive", true)
8785
}
8886
}
8987
func init() {
@@ -101,10 +99,10 @@ func init() {
10199
}
102100

103101
return &GoEngine{
104-
loader: loader,
105-
templateSet: template.New("__root__").Funcs(TemplateFuncs),
106-
templatesBylowerName: map[string]*GoTemplate{},
107-
splitDelims: splitDelims,
102+
loader: loader,
103+
templateSet: template.New("__root__").Funcs(TemplateFuncs),
104+
templatesByName: map[string]*GoTemplate{},
105+
splitDelims: splitDelims,
108106
}, nil
109107
})
110108
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.