Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Generic layout RHTML for Rails apps

This will not be 100% for everyone, but I use it for most of my apps and it does all the most important stuff I can't be bothered to retype each time.

(Updated August 2006 to slightly more up to date standards!)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title><%= @page_title %></title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<%= stylesheet_link_tag "main" %>
	<%= javascript_include_tag :defaults %>
</head>

<body<% if @page_class %> class="<%= @page_class %>"<% end %>>

	<% unless session[:user_id] %><%= render :partial => "generic/loginstuff" -%><% end %>

	<div id="container">
	
		<div id="header">
		</div>
	
		<% unless @message_override && @message_override == 1 %><%= render :partial => "generic/messageboxes" %><% end %>
	
		<div id="main">
			<%= yield %>
		</div>
	
		<div id="footer">
		</div>
	
	</div>

</body>
</html>

Zebra stripes on table rows using Rails / RHTML

<% @projects.each_with_index do |project, i| %>
<% row_class = i%2 == 0 ? "even" : "odd" %> 
<tr class="<%= row_class %>">
......
<% end %>


In the CSS:

TR.even { background-color: #f00; }
TR.odd { background-color: #f00; }


etc..
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS