I have a couple of views I'd like to have appear on every view that is rendered, but short of duplicating code or breaking the specifications, I can't seem to find a way to accomplish this.
Here's my current code, putting calls in every view:
def ImOnABoat::Views def layout html do head do title "Petstore" end body do yield end end end def navigation p "Welcome to our tiny petstore!" end def poodle navigation # Have to duplicate this in every view p "We have a poodle!" end def fluffy_bunny navigation # Have to duplicate this in every view p "Come see-- OH CRAP IT'S A VELOCIRAPTOR!" end end
I can also make it work by allowing the common blocks to render outside the body, but this is against specification and will probably end up horribly breaking some scraper scripts down the road.
def layout def head do title "Petstore" end nav # This is not inside <body>! def body do yield end end