Skip to content

Commit 19b4adb

Browse files
committed
chore: minor code cleanups
Signed-off-by: Abiola Ibrahim <[email protected]>
1 parent 1e232f3 commit 19b4adb

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

engine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616
defaultLayout string
1717

1818
// default filename extenstions for template files
19-
defaultExts = []string{"html", "gohtml", "tpl", "tmpl"}
19+
defaultExts = []string{".html", ".gohtml", ".tpl", ".tmpl"}
2020
)
2121

2222
const (
@@ -98,7 +98,7 @@ func walk(fsys fs.FS, exts []string, funcMap template.FuncMap) (set templateSet,
9898
}
9999

100100
ext := filepath.Ext(d.Name())
101-
if !validExt(exts, ext) {
101+
if !hasExt(exts, ext) {
102102
return nil
103103
}
104104

@@ -260,7 +260,7 @@ func readFile(fsys fs.FS, name string) (string, error) {
260260
return string(f), nil
261261
}
262262

263-
func validExt(exts []string, ext string) bool {
263+
func hasExt(exts []string, ext string) bool {
264264
if ext == "" {
265265
return false
266266
}
@@ -277,7 +277,7 @@ func validExt(exts []string, ext string) bool {
277277

278278
func validateLayoutFile(exts []string, name string) error {
279279
ext := filepath.Ext(name)
280-
if !validExt(exts, ext) {
280+
if !hasExt(exts, ext) {
281281
return fmt.Errorf("unsupported filename extension '%s'", ext)
282282
}
283283

engine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestValidExt(t *testing.T) {
100100

101101
for i, tt := range tests {
102102
t.Run(strconv.Itoa(i), func(t *testing.T) {
103-
result := validExt(tt.exts, tt.ext)
103+
result := hasExt(tt.exts, tt.ext)
104104
if result != tt.expected {
105105
t.Errorf("validExt(%v, %q) = %v, expected %v", tt.exts, tt.ext, result, tt.expected)
106106
}

mold.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func WithLayout(layout string) Option {
121121
// WithExt configures the filename extensions for the templates.
122122
// Only files with the specified extensions would be parsed.
123123
//
124-
// Default: ["html", "gohtml", "tpl", "tmpl"]
124+
// Default: [".html", ".gohtml", ".tpl", ".tmpl"]
125125
func WithExt(exts ...string) Option {
126126
return func(c *Config) { c.exts = newVal(exts) }
127127
}

mold_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func TestRender_PartialInvalidPartial(t *testing.T) {
259259
)
260260

261261
if _, err := New(testFS); err == nil {
262-
t.Errorf("New() expected error, got nil")
262+
t.Errorf("New() expected error, got nil")
263263
}
264264
}
265265

0 commit comments

Comments
 (0)