Results 1 to 7 of 7
Jun 3, 2006, 20:24 #1
How to break up my HTML for Rails
So I'm transitioning away from PHP/all-my-code-and-html-together to Rails. Half the time that's "woot" and the other half it's "whew" <laugh> A few questions now... :-)
I'm used to putting my website mast/navigation into, say, mast.php and then include()ing it from index.php, section1.php, etc.
Each of the main pages, what in Rails will be controllers, would set a variable like $page = 'index', $page = 'section1'. mast.php had automatic access to that variable and could do things with it... like, "If we're being called from section1, don't put a link around the section1 button... instead, show the section1_rollover graphic."
Now in Rails... I want to separate out the mast code (and keep DRY), but does it go in a normal controller/template pair, should it be a component, etc? I wouldn't want it to be able to be called from myapp.com/mast for example.
This may influence the answer: the mast html needs to get called from a layout file, which will also have other content_for_layout to render.
So the pieces are something like:
somecontroller wants to render someview, with somelayout wrapped around it...
somelayout wants to include the mastview
Finally, I anticipate the particular project I'm working on having about three layouts... each one needs to tell the mast controller if they have a sidebar or not, so that the mast view can render some bits of HTML one way versus another.
I have no idea how to pass that on to the mast controller from the layout :-)
Sorry if this is unclear, and I'm trying to ask several different things in one post. Just trying to wrap my head around how to do all of this, and I'm already so used to doing it the PHP way.