trvsdnn / frank

Static Site Non-Framework
http://github.com/blahed/frank
MIT License
413 stars 30 forks source link

Making layouts have layouts.. #80

Closed joesavage closed 12 years ago

joesavage commented 12 years ago

I've almost finished creating a static site generation system for my tutorial website using Frank, however one issue I seem to have come across is that layouts can't have layouts.

This means that I have different layouts for "tutorial_show", "category_show", and so on, which serve all of the tutorial and category pages, however these layouts in themselves cannot share the theme of the website. The result of this is that if I want to change a simple link in the website's footer - I have to change it in all four layouts instead of being able to change a link in a master layout which serves all of the more specific layouts (which serve all of my specific types of pages).

Is there any current solution to this and is this something you're considering implementing in the upcoming refactor?

joesavage commented 12 years ago

@blahed Are partials the solution here? When trying to use partials in my project layouts I keep getting a "Template not found" error, no matter where I try putting the layouts or setting the location of the partial.

trvsdnn commented 12 years ago

Usually, for shared content, partials are the best way to handle it. Frank tries to be close to sinatra/rails in that regard. The partials will actually be in the dynamic directory with your normal "page" files. The filename needs to begin with an underscore.

joesavage commented 12 years ago

Partials seem a great way to handle it, but I'm setting wrestling with this "Template not found" error. When I put a folder in 'dynamic' called 'partials' and put '_start.html' or '_start.erb' in here as my partial - an attempt at a partial render via <%= render_partial 'partials/start' %> in my layout file results in Template not found /partials/_start.html (Frank::TemplateError). Presumably it's looking for dynamic/partials/_start.html, which is exactly where my file is located - so I have no idea why it can't find it.

I've tried changing all kinds of names and paths (removing the partials directory and putting things straight into dynamic, giving an exact folder to the location of the partial, using ../ to try and get to the right place, putting the partials in the layouts folder) but it just can't seem to find my partial whatever I try to do. Are partials broken for use in layouts?

Any help would be greatly appreciated.

trvsdnn commented 12 years ago

I just tested this using the default Frank projected and it works as expected. You can't use .html as partials, it must actually be .erb or another template language, not sure if that's the issue.

I had a partials folder in dynamic with a _test.haml and my render_partial method looked like this: render_partial('partials/test')

joesavage commented 12 years ago

Oh wow, super weird, it's working now. Problem solved - thanks!

trvsdnn commented 12 years ago

I need to cleanup the docs and clarify a lot of things. It's on my list for the next release.