diff --git a/render.go b/render.go
index 3bf5d36..ec9dbb7 100644
--- a/render.go
+++ b/render.go
@@ -360,7 +360,7 @@ func (r *Render) compileTemplatesFromAsset() {
ext := ""
if strings.Contains(rel, ".") {
- ext = "." + strings.Join(strings.Split(rel, ".")[1:], ".")
+ ext = filepath.Ext(rel) // match the directory walker: only the final extension
}
for _, extension := range r.opt.Extensions {
diff --git a/render_html_test.go b/render_html_test.go
index 4ce17f0..08e167e 100644
--- a/render_html_test.go
+++ b/render_html_test.go
@@ -524,3 +524,33 @@ func TestHTMLPerCallContentType(t *testing.T) {
expect(t, res.Header().Get(ContentType), "application/xhtml+xml")
expect(t, res.Body.String(), "
Hello gophers
\n")
}
+
+var dotDirFiles = map[string]string{
+ "testdata/dotdir/users.tmpl/index.tmpl": "Hello asset",
+ "testdata/dotdir/a.b.tmpl": "Hello ab",
+}
+
+// The asset loader must select templates by the same extension rule as the
+// directory walker, including under a dot-named directory and for multi-dot names.
+func TestHTMLAssetExtensionMatchesDirectory(t *testing.T) {
+ names := make([]string, 0, len(dotDirFiles))
+ for n := range dotDirFiles {
+ names = append(names, n)
+ }
+
+ dirRender := New(Options{Directory: "testdata/dotdir"})
+ assetRender := New(Options{
+ Directory: "testdata/dotdir",
+ Asset: func(n string) ([]byte, error) { return []byte(dotDirFiles[n]), nil },
+ AssetNames: func() []string { return names },
+ })
+
+ for _, name := range []string{"users.tmpl/index", "a.b"} {
+ if dirRender.TemplateLookup(name) == nil {
+ t.Errorf("directory mode did not load %q", name)
+ }
+ if assetRender.TemplateLookup(name) == nil {
+ t.Errorf("asset mode did not load %q", name)
+ }
+ }
+}
diff --git a/testdata/dotdir/a.b.tmpl b/testdata/dotdir/a.b.tmpl
new file mode 100644
index 0000000..7fcc02d
--- /dev/null
+++ b/testdata/dotdir/a.b.tmpl
@@ -0,0 +1 @@
+Hello ab
\ No newline at end of file
diff --git a/testdata/dotdir/users.tmpl/index.tmpl b/testdata/dotdir/users.tmpl/index.tmpl
new file mode 100644
index 0000000..4d0ae53
--- /dev/null
+++ b/testdata/dotdir/users.tmpl/index.tmpl
@@ -0,0 +1 @@
+Hello asset
\ No newline at end of file