2006-01-09 02:55:47 Rails in the HTML
Is this really the way developers want to make their HTML code?
( rhtml )
  1  <h1>Online Cookbook — All Recipes</h1>
2
<table border="1">
3
<tr>
4
<td width="80%"><p align="center"><i><b>Recipe</b></i></td>
5
<td width="20%"><p align="center"><i><b>Date</b></i></td>
6
</tr>
7
8
<% @recipes.each do |recipe| %>
9
<tr>
10
<td><%= link_to recipe.title, :action => "show", :id => recipe.id %></td>
11
<td><%= recipe.date %></td>
12
</tr>
13
<% end %>
14
</table>
15
<p><%= link_to "Create new recipe", :action => "new" %></p>


I'll explain my rationale for this later, but here's a teaser of how i'd write this (just rewriting the relevant block):
( html )
  1 
2 <field: recipe>
3 <tr>
4 <td><field: recipeLink /></td>
5 <td><field: recipeDate /></td>
6 </tr>
7 </field: recipe>
8 </table>
9 <p><field: newRecipeLink /></p>


Let the web page designers work in pure xhtml, and let the coders turn the field tags into data-based things. No mixing of duties. This seems to me to be an actual separation of model and view as well as a proper separation of duties among members of a team.
  • jv (Tue, February 7th, 2006, 6:54am UTC)

  • Jeff (Tue, February 7th, 2006, 1:51pm UTC)
    That is certainly better! Thanks for showing me that, jv. This site uses the field tag system displayed above, but soon I have to work on a rails project and will see about using amrita for that.

  • Nils (Wed, September 27th, 2006, 4:47am UTC)
    There also is an Amrita2-Rails bridge!

    How to use Amrita2 with Ruby On Rails

    http://amrita2.rubyforge.org/Rails.html

Leave a comment