laktek / punch

A fun and easy way to build modern websites
http://laktek.github.com/punch
MIT License
1.17k stars 107 forks source link

Conflict when a templates subdirectory has same name as a top level rendered page. #66

Open corporealfunk opened 11 years ago

corporealfunk commented 11 years ago

Punch version 0.5.14

Given a project with a templates/_layout.mustache file and a contents/test.json file, when using the punch server, visiting localhost:9009/test.html renders correctly.

Now, from the project root:

mkdir templates/test
echo "this is the static content under test/index.html" > templates/test/index.html

Visit: localhost:9009/test.html and we should see the test.json data templated via the _layout.mustache file as before, however, we see:

"this is the static content under test/index.html"

We should only see that content if we visit: localhost:9009/test/index.html or localhost:9009/test/

This appears to be a problem during generation as well, but in a slightly different way. Only the "test/index.html" file is generated, the "test.html" is not generated.

laktek commented 11 years ago

If you have a directory and a file by the same name, the directory index will override the file.

Is there a particular use case you want to use the same name for a directory and a file?

On Fri, Feb 8, 2013 at 12:55 PM, Jon Moniaci notifications@github.comwrote:

Punch version 0.5.14

Given a project with a templates/_layout.mustache file and a contents/test.json file, when using the punch server, visiting localhost:9009/test.html renders correctly.

Now, from the project root:

mkdir templates/test echo "this is the static content under test/index.html" > templates/test/index.html

Visit: localhost:9009/test.html and we should see the test.json data templated via the _layout.mustache file as before, however, we see:

"this is the static content under test/index.html"

We should only see that content if we visit: localhost:9009/test/index.html or localhost:9009/test/

This appears to be a problem during generation as well, but in a slightly different way. Only the "test/index.html" file is generated, the "test.html" is not generated.

— Reply to this email directly or view it on GitHubhttps://github.com/laktek/punch/issues/66.

corporealfunk commented 11 years ago

Webservers such as Apache, NGINX, etc. serve this use case without difficulty and I am currently dealing with a legacy site structure that uses naming conventions like these.

I'm actually curious as to why this is a design feature of punch, these two paths are quite different:

test.html test/index.html

Why should they not be allowed to be generated and serve different content?