Include HTML

Hi,

how do you include html into a web page.

e.g i have a menu that is present on every page so i want to include it.

also would this go in the public directory where the stylesheet
directory resides

matt wrote:

Hi,

how do you include html into a web page.

e.g i have a menu that is present on every page so i want to include it.

also would this go in the public directory where the stylesheet
directory resides

I am new to rails but as I know you can put code in the
application.rhtml - that will appear in every page

i have a menu in my app too and use
<%= render :partial => “shared/header” %>
to include it

andreas

thanks for your reply…could you give an example?

On Fri, 2006-11-03 at 13:56 +0100, matt wrote:

Hi,

how do you include html into a web page.

e.g i have a menu that is present on every page so i want to include it.

also would this go in the public directory where the stylesheet
directory resides


sounds like something that should go on a layout…

app/views/layouts

http://rails.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html

Craig

The app/layouts/application.rhtml file will “wrap” your entire website,
if you like. You could create your basic layout in this file, including
your menu that should be everywhere, and at the point in your layout
that the dymamic content from your rails application would go, you would
put:

<%= yield %>

(Used to be content_for_layout)

Whenever you hit a piece of your application, the view for the
method/action will be inserted where the “yield” is and the entire page
will be returned. The AWDWR book has an excellent overview of how this
works in the tutorial.

Now, if you do not want to use the application layout, you can create a
partial - that is, a view with the just code for your menu - and put it
into one of the folders under app/views, with a name that begins with an
underscore, like “_nav_menu.rhtml”. Then, anywhere you want to display
that menu in a view, you would call it as a partial. Many people will
create a common folder under app/views for this kind of stuff, like the
previous poster who suggested putting it into
“app/views/shared/_nav_menu.rhtml”. Then, you would call the partial
with the following:

<%= render :partial => ‘shared/nav_menu’ %>

Note that in the render call for a partial, you do not use the
underscore or the .rhtml prefix - rails knows.

c.

matt wrote:

thanks for your reply…could you give an example?