cloudhead / toto

the 10 second blog-engine for hackers
MIT License
1.48k stars 245 forks source link

Alternate Layout File #61

Open beckelmw opened 13 years ago

beckelmw commented 13 years ago

Is it possible to change which layout is used like you can with Sinatra? It would be nice to be able to send a different layout to mobile browsers.

jbrains commented 12 years ago

I would like to do this in the style of tumblr: image, video, quote, text...

ixti commented 12 years ago

Basically you can provide your lambda in config:

set :to_html, lambda {|path, page, ctx| # returns an html, from a path & context
  if :layout == page
    # override page here
  end
  ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
}

but I'm not sure how you will "determine" when to switch over. I guess you wont' be able with current API (personally for me this feature seems useless)