trvsdnn / frank

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

Pages templates should render before their layouts #10

Closed jacquescrocker closed 14 years ago

jacquescrocker commented 14 years ago

A common pattern in rails is to use a helper within a template to set an instance variable, that can then be used within the layout. However since the layout is running first.

Layout and template should also use the same "scope".

Here's the exact use case:

# in helpers.rb
module FrankHelpers
  def title(val = nil)
    @title = val if val
    @title || ""
  end
end

# in layouts/default.haml
!!! Strict
%html{html_attrs}
  %head
    %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
    %title= title
  %body
    = yield

# in dynamic/index.haml
- title "Home Page"
Content...
jacquescrocker commented 14 years ago

This is now fixed in http://github.com/blahed/frank/commit/da48a6e5a9d4f9382da0d6f1c6f76e9b984f2172

0.4 is ready to rock! :-)

Msg me on skype anytime (skype name: jcnetdev) and we can talk about some of my zany 0.5 ideas