Changeset 6178
- Timestamp:
- 02/20/07 22:09:12 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/examples/address_book/index.rhtml (modified) (1 diff)
- trunk/actionpack/examples/address_book/layout.rhtml (modified) (1 diff)
- trunk/actionpack/examples/debate/index.rhtml (modified) (1 diff)
- trunk/actionpack/examples/debate/new_topic.rhtml (modified) (1 diff)
- trunk/actionpack/examples/debate/topic.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (6 diffs)
- trunk/actionpack/lib/action_controller/flash.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/layout.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/rescue.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/scaffolding.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/_trace.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/layout.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/missing_template.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/routing_error.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/template_error.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/unknown_action.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/scaffolds/list.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/scaffolds/new.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/scaffolds/show.rhtml (modified) (1 diff)
- trunk/actionpack/lib/action_view/base.rb (modified) (11 diffs)
- trunk/actionpack/lib/action_view/helpers/capture_helper.rb (modified) (4 diffs)
- trunk/actionpack/lib/action_view/partials.rb (modified) (4 diffs)
- trunk/actionpack/README (modified) (2 diffs)
- trunk/actionpack/test/controller/layout_test.rb (modified) (1 diff)
- trunk/actionpack/test/controller/new_render_test.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/rescue_test.rb (modified) (1 diff)
- trunk/actionpack/test/fixtures/addresses/list.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_flash_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_headers_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_params_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_request_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_response_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/deprecated_instance_variables/_session_method.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/fun/games/hello_world.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/layouts/builder.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/layouts/standard.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/layouts/talk_from_action.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/layouts/yield.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/override/test/hello_world.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/scope/test/modgreet.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_customer_greeting.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_customer.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_hash_object.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_hello.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_partial_only.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/_person.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/action_talk_to_layout.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/block_content_for.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/capturing.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/content_for.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/erb_content_for.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/greeting.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello_world_container.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello_world_with_layout_false.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello_world.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello_world.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello_xml_world.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/hello.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/list.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/non_erb_block_content_for.rxml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/potential_conflicts.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/render_file_with_ivar.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/render_file_with_locals.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/render_to_string_test.rhtml (modified) (1 diff)
- trunk/actionpack/test/fixtures/test/update_element_with_capture.rhtml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6164 r6178 1 1 *SVN* 2 3 * Added .erb and .builder as preferred aliases to the now deprecated .rhtml and .rxml extensions [Chad Fowler]. This is done to separate the renderer from the mime type. .erb templates are often used to render emails, atom, csv, whatever. So labeling them .rhtml doesn't make too much sense. The same goes for .rxml, which can be used to build everything from HTML to Atom to whatever. .rhtml and .rxml will continue to work until Rails 3.0, though. So this is a slow phasing out. All generators and examples will start using the new aliases, though. 2 4 3 5 * Added caching option to AssetTagHelper#stylesheet_link_tag and AssetTagHelper#javascript_include_tag [DHH]. Examples: trunk/actionpack/examples/address_book/index.rhtml
r4 r6178 1 <h1>Address Book</h1>2 3 <% if @people.empty? %>4 <p>No people in the address book yet</p>5 <% else %>6 <table>7 <tr><th>Name</th><th>Email Address</th><th>Phone Number</th></tr>8 <% for person in @people %>9 <tr><td><%= person.name %></td><td><%= person.email_address %></td><td><%= person.phone_number %></td></tr>10 <% end %>11 </table>12 <% end %>13 14 <form action="create_person">15 <p>16 Name:<br />17 <input type="text" name="person[name]">18 </p>19 20 <p>21 Email address:<br />22 <input type="text" name="person[email_address]">23 </p>24 25 <p>26 Phone number:<br />27 <input type="text" name="person[phone_number]">28 </p>29 30 <p>31 <input type="submit" value="Create Person">32 </p>33 </form>trunk/actionpack/examples/address_book/layout.rhtml
r4 r6178 1 <html>2 <head>3 <title><%= @title || "Untitled" %></title>4 </head>5 <body>6 <%= @content_for_layout %>7 </body>8 </html>trunk/actionpack/examples/debate/index.rhtml
r4 r6178 1 <html>2 <body>3 <h1>Topics</h1>4 5 <%= link_to "New topic", :action => "new_topic" %>6 7 <ul>8 <% for topic in @topics %>9 <li><%= link_to "#{topic.title} (#{topic.replies.length} replies)", :action => "topic", :path_params => { "id" => topic.id } %></li>10 <% end %>11 </ul>12 13 </body>14 </html>trunk/actionpack/examples/debate/new_topic.rhtml
r4 r6178 1 <html>2 <body>3 <h1>New topic</h1>4 5 <form action="<%= url_for(:action => "create_topic") %>" method="post">6 <p>7 Title:<br>8 <input type="text" name="topic[title]">9 </p>10 11 <p>12 Body:<br>13 <textarea name="topic[body]" style="width: 200px; height: 200px"></textarea>14 </p>15 16 <p>17 <input type="submit" value="Create topic">18 </p>19 </form>20 21 </body>22 </html>trunk/actionpack/examples/debate/topic.rhtml
r4 r6178 1 <html>2 <body>3 <h1><%= @topic.title %></h1>4 5 <p><%= @topic.body %></p>6 7 <%= link_to "Back to topics", :action => "index" %>8 9 <% unless @topic.replies.empty? %>10 <h2>Replies</h2>11 <ol>12 <% for reply in @topic.replies %>13 <li><%= reply.body %></li>14 <% end %>15 </ol>16 <% end %>17 18 <h2>Reply to this topic</h2>19 20 <form action="<%= url_for(:action => "create_reply") %>" method="post">21 <input type="hidden" name="reply[topic_id]" value="<%= @topic.id %>">22 <p>23 <textarea name="reply[body]" style="width: 200px; height: 200px"></textarea>24 </p>25 26 <p>27 <input type="submit" value="Create reply">28 </p>29 </form>30 31 </body>32 </html>trunk/actionpack/lib/action_controller/base.rb
r6165 r6178 72 72 # Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action 73 73 # after executing code in the action. For example, the +index+ action of the +GuestBookController+ would render the 74 # template <tt>app/views/guestbook/index. rhtml</tt> by default after populating the <tt>@entries</tt> instance variable.74 # template <tt>app/views/guestbook/index.erb</tt> by default after populating the <tt>@entries</tt> instance variable. 75 75 # 76 76 # Unlike index, the sign action will not render a template. After performing its main purpose (creating a … … 663 663 # The current layout is automatically applied. 664 664 # 665 # # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show. rhtml)665 # # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show.erb) 666 666 # render :template => "weblog/show" 667 667 # … … 672 672 # 673 673 # # Renders the template located at the absolute filesystem path 674 # render :file => "/path/to/some/template. rhtml"675 # render :file => "c:/path/to/some/template. rhtml"674 # render :file => "/path/to/some/template.erb" 675 # render :file => "c:/path/to/some/template.erb" 676 676 # 677 677 # # Renders a template within the current layout, and with a 404 status code 678 # render :file => "/path/to/some/template. rhtml", :layout => true, :status => 404679 # render :file => "c:/path/to/some/template. rhtml", :layout => true, :status => 404678 # render :file => "/path/to/some/template.erb", :layout => true, :status => 404 679 # render :file => "c:/path/to/some/template.erb", :layout => true, :status => 404 680 680 # 681 681 # # Renders a template relative to the template root and chooses the proper file extension … … 735 735 # 736 736 # # Renders "<p>Good seeing you!</p>" using Builder 737 # render :inline => "xml.p { 'Good seeing you!' }", :type => : rxml737 # render :inline => "xml.p { 'Good seeing you!' }", :type => :builder 738 738 # 739 739 # # Renders "hello david" … … 864 864 end 865 865 866 def render_template(template, status = nil, type = : rhtml, local_assigns = {}) #:nodoc:866 def render_template(template, status = nil, type = :erb, local_assigns = {}) #:nodoc: 867 867 add_variables_to_assigns 868 868 render_text(@template.render_template(type, template, nil, local_assigns), status) … … 1253 1253 def assert_existence_of_template_file(template_name) 1254 1254 unless template_exists?(template_name) || ignore_missing_templates 1255 full_template_path = @template.send(:full_template_path, template_name, ' rhtml')1255 full_template_path = @template.send(:full_template_path, template_name, 'erb') 1256 1256 template_type = (template_name =~ /layouts/i) ? 'layout' : 'template' 1257 1257 raise(MissingTemplate, "Missing #{template_type} #{full_template_path}") trunk/actionpack/lib/action_controller/flash.rb
r5021 r6178 17 17 # end 18 18 # 19 # display. rhtml19 # display.erb 20 20 # <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %> 21 21 # trunk/actionpack/lib/action_controller/layout.rb
r6120 r6178 65 65 # If there is a template in <tt>app/views/layouts/</tt> with the same name as the current controller then it will be automatically 66 66 # set as that controller's layout unless explicitly told otherwise. Say you have a WeblogController, for example. If a template named 67 # <tt>app/views/layouts/weblog. rhtml</tt> or <tt>app/views/layouts/weblog.rxml</tt> exists then it will be automatically set as68 # the layout for your WeblogController. You can create a layout with the name <tt>application. rhtml</tt> or <tt>application.rxml</tt>67 # <tt>app/views/layouts/weblog.erb</tt> or <tt>app/views/layouts/weblog.builder</tt> exists then it will be automatically set as 68 # the layout for your WeblogController. You can create a layout with the name <tt>application.erb</tt> or <tt>application.builder</tt> 69 69 # and this will be set as the default controller if there is no layout with the same name as the current controller and there is 70 70 # no layout explicitly assigned with the +layout+ method. Nested controllers use the same folder structure for automatic layout. 71 # assignment. So an Admin::WeblogController will look for a template named <tt>app/views/layouts/admin/weblog. rhtml</tt>.71 # assignment. So an Admin::WeblogController will look for a template named <tt>app/views/layouts/admin/weblog.erb</tt>. 72 72 # Setting a layout explicitly will always override the automatic behaviour for the controller where the layout is set. 73 73 # Explicitly setting the layout in a parent class, though, will not override the child class's layout assignement if the child trunk/actionpack/lib/action_controller/rescue.rb
r5966 r6178 153 153 154 154 def rescues_path(template_name) 155 "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}. rhtml"155 "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.erb" 156 156 end 157 157 trunk/actionpack/lib/action_controller/scaffolding.rb
r4973 r6178 72 72 # end 73 73 # 74 # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show. rhtml" for74 # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.erb" for 75 75 # the show action) and if not, then render the generic template for that action. This gives you the possibility of using the 76 76 # scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template … … 177 177 178 178 def scaffold_path(template_name) 179 File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ". rhtml"179 File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".erb" 180 180 end 181 181 trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml
r5504 r6178 1 <% unless @exception.blamed_files.blank? %>2 <% if (hide = @exception.blamed_files.length > 8) %>3 <a href="#" onclick="document.getElementById('blame_trace').style.display='block'; return false;">Show blamed files</a>4 <% end %>5 <pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre>6 <% end %>7 8 <% if false %>9 <br /><br />10 <% begin %>11 <%= form_tag(request.request_uri, "method" => request.method) %>12 <input type="hidden" name="BP-RETRY" value="1" />13 14 <% for key, values in params %>15 <% next if key == "BP-RETRY" %>16 <% for value in Array(values) %>17 <input type="hidden" name="<%= key %>" value="<%= value %>" />18 <% end %>19 <% end %>20 21 <input type="submit" value="Retry with Breakpoint" />22 </form>23 <% rescue Exception => e %>24 <%=h "Couldn't render breakpoint link due to #{e.class} #{e.message}" %>25 <% end %>26 <% end %>27 28 <%29 clean_params = request.parameters.clone30 clean_params.delete("action")31 clean_params.delete("controller")32 33 request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n")34 %>35 36 <h2 style="margin-top: 30px">Request</h2>37 <p><b>Parameters</b>: <pre><%=h request_dump %></pre></p>38 39 <p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>40 <div id="session_dump" style="display:none"><%= debug(request.session.instance_variable_get("@data")) %></div>41 42 43 <h2 style="margin-top: 30px">Response</h2>44 <p><b>Headers</b>: <pre><%=h response ? response.headers.inspect.gsub(',', ",\n") : 'None' %></pre></p>trunk/actionpack/lib/action_controller/templates/rescues/_trace.rhtml
r3839 r6178 1 <%2 traces = [3 ["Application Trace", @exception.application_backtrace],4 ["Framework Trace", @exception.framework_backtrace],5 ["Full Trace", @exception.clean_backtrace]6 ]7 names = traces.collect {|name, trace| name}8 %>9 10 <p><code>RAILS_ROOT: <%= defined?(RAILS_ROOT) ? RAILS_ROOT : "unset" %></code></p>11 12 <div id="traces">13 <% names.each do |name| -%>14 <%15 show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';"16 hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"}17 %>18 <a href="#" onclick="<%= hide %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>19 <% end -%>20 21 <% traces.each do |name, trace| -%>22 <div id="<%= name.gsub /\s/, '-' %>" style="display: <%= name == "Application Trace" ? 'block' : 'none' %>;">23 <pre><code><%= trace.join "\n" %></code></pre>24 </div>25 <% end -%>26 </div>trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml
r5201 r6178 1 <h1>2 <%=h @exception.class.to_s %>3 <% if request.parameters['controller'] %>4 in <%=h request.parameters['controller'].humanize %>Controller<% if request.parameters['action'] %>#<%=h request.parameters['action'] %><% end %>5 <% end %>6 </h1>7 <pre><%=h @exception.clean_message %></pre>8 9 <%= render_file(@rescues_path + "/_trace.rhtml", false) %>10 11 <%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %>trunk/actionpack/lib/action_controller/templates/rescues/layout.rhtml
r4 r6178 1 <html>2 <head>3 <title>Action Controller: Exception caught</title>4 <style>5 body { background-color: #fff; color: #333; }6 7 body, p, ol, ul, td {8 font-family: verdana, arial, helvetica, sans-serif;9 font-size: 13px;10 line-height: 18px;11 }12 13 pre {14 background-color: #eee;15 padding: 10px;16 font-size: 11px;17 }18 19 a { color: #000; }20 a:visited { color: #666; }21 a:hover { color: #fff; background-color:#000; }22 </style>23 </head>24 <body>25 26 <%= @contents %>27 28 </body>29 </html>trunk/actionpack/lib/action_controller/templates/rescues/missing_template.rhtml
r4 r6178 1 <h1>Template is missing</h1>2 <p><%=h @exception.message %></p>trunk/actionpack/lib/action_controller/templates/rescues/routing_error.rhtml
r4445 r6178 1 <h1>Routing Error</h1>2 <p><pre><%=h @exception.message %></pre></p>3 <% unless @exception.failures.empty? %><p>4 <h2>Failure reasons:</h2>5 <ol>6 <% @exception.failures.each do |route, reason| %>7 <li><code><%=h route.inspect.gsub('\\', '') %></code> failed because <%=h reason.downcase %></li>8 <% end %>9 </ol>10 </p><% end %>trunk/actionpack/lib/action_controller/templates/rescues/template_error.rhtml
r5315 r6178 1 <h1>2 <%=h @exception.original_exception.class.to_s %> in3 <%=h request.parameters["controller"].capitalize if request.parameters["controller"]%>#<%=h request.parameters["action"] %>4 </h1>5 6 <p>7 Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised:8 <pre><code><%=h @exception.message %></code></pre>9 </p>10 11 <p>Extracted source (around line <b>#<%=h @exception.line_number %></b>):12 <pre><code><%=h @exception.source_extract %></code></pre></p>13 14 <p><%=h @exception.sub_template_message %></p>15 16 <% @real_exception = @exception17 @exception = @exception.original_exception || @exception %>18 <%= render_file(@rescues_path + "/_trace.rhtml", false) %>19 <% @exception = @real_exception %>20 21 <%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %>trunk/actionpack/lib/action_controller/templates/rescues/unknown_action.rhtml
r4 r6178 1 <h1>Unknown action</h1>2 <p><%=h @exception.message %></p>trunk/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml
r1404 r6178 1 <h1>Editing <%= @scaffold_singular_name %></h1>2 3 <%= error_messages_for(@scaffold_singular_name) %>4 <%= form(@scaffold_singular_name, :action => "update#{@scaffold_suffix}") %>5 6 <%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |7 <%= link_to "Back", :action => "list#{@scaffold_suffix}" %>trunk/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml
r4262 r6178 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"2 "http://www.w3.org/TR/html4/loose.dtd">3 <html>4 <head>5 <title>Scaffolding</title>6 <style>7 body { background-color: #fff; color: #333; }8 9 body, p, ol, ul, td {10 font-family: verdana, arial, helvetica, sans-serif;11 font-size: 13px;12 line-height: 18px;13 }14 15 pre {16 background-color: #eee;17 padding: 10px;18 font-size: 11px;19 }20 21 a { color: #000; }22 a:visited { color: #666; }23 a:hover { color: #fff; background-color:#000; }24 25 .fieldWithErrors {26 padding: 2px;27 background-color: red;28 display: table;29 }30 31 #errorExplanation {32 width: 400px;33 border: 2px solid red;34 padding: 7px;35 padding-bottom: 12px;36 margin-bottom: 20px;37 background-color: #f0f0f0;38 }39 40 #errorExplanation h2 {41 text-align: left;42 font-weight: bold;43 padding: 5px 5px 5px 15px;44 font-size: 12px;45 margin: -7px;46 background-color: #c00;47 color: #fff;48 }49 50 #errorExplanation p {51 color: #333;52 margin-bottom: 0;53 padding: 5px;54 }55 56 #errorExplanation ul li {57 font-size: 12px;58 list-style: square;59 }60 </style>61 </head>62 <body>63 64 <p style="color: green"><%= flash[:notice] %></p>65 66 <%= yield %>67 68 </body>69 </html>trunk/actionpack/lib/action_controller/templates/scaffolds/list.rhtml
r5366 r6178 1 <h1>Listing <%= @scaffold_plural_name %></h1>2 3 <table>4 <tr>5 <% for column in @scaffold_class.content_columns %>6 <th><%= column.human_name %></th>7 <% end %>8 </tr>9 10 <% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>11 <tr>12 <% for column in @scaffold_class.content_columns %>13 <td><%= entry.send(column.name) %></td>14 <% end %>15 <td><%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %></td>16 <td><%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %></td>17 <td><%= link_to "Destroy", {:action => "destroy#{@scaffold_suffix}", :id => entry}, { :confirm => "Are you sure?", :method => :post } %></td>18 </tr>19 <% end %>20 </table>21 22 <%= link_to "Previous page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous %>23 <%= link_to "Next page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.next } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.next %>24 25 <br />26 27 <%= link_to "New #{@scaffold_singular_name}", :action => "new#{@scaffold_suffix}" %>trunk/actionpack/lib/action_controller/templates/scaffolds/new.rhtml
r1404 r6178 1 <h1>New <%= @scaffold_singular_name %></h1>2 3 <%= error_messages_for(@scaffold_singular_name) %>4 <%= form(@scaffold_singular_name, :action => "create#{@scaffold_suffix}") %>5 6 <%= link_to "Back", :action => "list#{@scaffold_suffix}" %>trunk/actionpack/lib/action_controller/templates/scaffolds/show.rhtml
r1404 r6178 1 <% for column in @scaffold_class.content_columns %>2 <p>3 <b><%= column.human_name %>:</b>4 <%= instance_variable_get("@#{@scaffold_singular_name}").send(column.name) %>5 </p>6 <% end %>7 8 <%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |9 <%= link_to "Back", :action => "list#{@scaffold_suffix}" %>trunk/actionpack/lib/action_view/base.rb
r6132 r6178 5 5 end 6 6 7 # Action View templates can be written in three ways. If the template file has a +. rhtml+extension then it uses a mixture of ERb8 # (included in Ruby) and HTML. If the template file has a +. rxml+extension then Jim Weirich's Builder::XmlMarkup library is used.7 # Action View templates can be written in three ways. If the template file has a +.erb+ (or +.rhtml+) extension then it uses a mixture of ERb 8 # (included in Ruby) and HTML. If the template file has a +.builder+ (or +.rxml+) extension then Jim Weirich's Builder::XmlMarkup library is used. 9 9 # If the template file has a +.rjs+ extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator. 10 10 # … … 78 78 # 79 79 # Builder templates are a more programmatic alternative to ERb. They are especially useful for generating XML content. An +XmlMarkup+ object 80 # named +xml+ is automatically made available to templates with a +. rxml+ extension.80 # named +xml+ is automatically made available to templates with a +.builder+ extension. 81 81 # 82 82 # Here are some basic examples: … … 247 247 @first_render ||= template_path 248 248 template_path_without_extension, template_extension = path_and_extension(template_path) 249 250 249 if use_full_path 251 250 if template_extension … … 281 280 update_page(&block) 282 281 elsif options.is_a?(Hash) 283 options = options.reverse_merge(:type => : rhtml, :locals => {}, :use_full_path => true)282 options = options.reverse_merge(:type => :erb, :locals => {}, :use_full_path => true) 284 283 285 284 if options[:file] … … 295 294 end 296 295 297 # Renders the +template+ which is given as a string as either rhtml or rxmldepending on <tt>template_extension</tt>.296 # Renders the +template+ which is given as a string as either erb or builder depending on <tt>template_extension</tt>. 298 297 # The hash in <tt>local_assigns</tt> is made available as local variables. 299 298 def render_template(template_extension, template, file_path = nil, local_assigns = {}) #:nodoc: … … 343 342 @@template_handlers.find { |k,| template_exists?(template_path, k) } 344 343 end 345 344 345 def one_of(template_path, *extensions)#:nodoc: 346 extensions.detect{|ext| template_exists?(template_path, ext)} 347 end 348 346 349 def erb_template_exists?(template_path)#:nodoc: 347 template_exists?(template_path, :rhtml) 348 end 349 350 one_of(template_path, :erb, :rhtml) 351 end 352 alias :rhtml_template_exists? :erb_template_exists? 353 350 354 def builder_template_exists?(template_path)#:nodoc: 351 template_exists?(template_path, :rxml) 352 end 353 355 one_of(template_path, :builder, :rxml) 356 end 357 alias :rxml_template_exists? :builder_template_exists? 358 354 359 def javascript_template_exists?(template_path)#:nodoc: 355 360 template_exists?(template_path, :rjs) … … 362 367 else 363 368 cached_template_extension(template_path) || 364 %w(erb builderjavascript delegate).any? do |template_type|369 %w(erb rhtml builder rxml javascript delegate).any? do |template_type| 365 370 send("#{template_type}_template_exists?", template_path) 366 371 end … … 402 407 if match = delegate_template_exists?(template_path) 403 408 match.first.to_sym 404 elsif e rb_template_exists?(template_path): :rhtml405 elsif builder_template_exists?(template_path): :rxml409 elsif extension = erb_template_exists?(template_path): extension 410 elsif extension = builder_template_exists?(template_path): extension 406 411 elsif javascript_template_exists?(template_path): :rjs 407 412 else 408 raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path} in #{@view_paths.inspect}"413 raise ActionViewError, "No erb, builder, rhtml, rxml, rjs or delegate template found for #{template_path} in #{@view_paths.inspect}" 409 414 end 410 415 end … … 465 470 if template_requires_setup?(extension) 466 471 body = case extension.to_sym 467 when :rxml 472 when :rxml, :builder 468 473 "controller.response.content_type ||= 'application/xml'\n" + 469 474 "xml = Builder::XmlMarkup.new(:indent => 2)\n" + … … 494 499 495 500 def templates_requiring_setup 496 %w( rxml rjs)501 %w(builder rxml rjs) 497 502 end 498 503 … … 524 529 if extension 525 530 case extension.to_sym 526 when : rxml, :rjs531 when :builder, :rxml, :rjs 527 532 line_offset += 2 528 533 end trunk/actionpack/lib/action_view/helpers/capture_helper.rb
r5544 r6178 15 15 # make the fragment available by name to a yielding layout or template. 16 16 # 17 # layout. rhtml:17 # layout.erb: 18 18 # 19 19 # <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> … … 29 29 # </html> 30 30 # 31 # view. rhtml31 # view.erb 32 32 # 33 33 # This page shows an alert box! … … 43 43 # in your templates and even in your layout. 44 44 # 45 # Example of capture being used in a . rhtmlpage:45 # Example of capture being used in a .erb page: 46 46 # 47 47 # <% @greeting = capture do %> … … 49 49 # <% end %> 50 50 # 51 # Example of capture being used in a . rxmlpage:51 # Example of capture being used in a .builder page: 52 52 # 53 53 # @greeting = capture do trunk/actionpack/lib/action_view/partials.rb
r3073 r6178 8 8 # <%= render :partial => "account" %> 9 9 # 10 # This would render "advertiser/_account. rhtml" and pass the instance variable @account in as a local variable +account+ to10 # This would render "advertiser/_account.erb" and pass the instance variable @account in as a local variable +account+ to 11 11 # the template for display. 12 12 # … … 19 19 # <% end %> 20 20 # 21 # This would first render "advertiser/_account. rhtml" with @buyer passed in as the local variable +account+, then render22 # "advertiser/_ad. rhtml" and pass the local variable +ad+ to the template for display.21 # This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then render 22 # "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. 23 23 # 24 24 # == Rendering a collection of partials … … 31 31 # <%= render :partial => "ad", :collection => @advertisements %> 32 32 # 33 # This will render "advertiser/_ad. rhtml" and pass the local variable +ad+ to the template for display. An iteration counter33 # This will render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. An iteration counter 34 34 # will automatically be made available to the template with a name of the form +partial_name_counter+. In the case of the 35 35 # example above, the template would be fed +ad_counter+. … … 44 44 # <%= render :partial => "advertisement/ad", :locals => { :ad => @advertisement } %> 45 45 # 46 # This will render the partial "advertisement/_ad. rhtml" regardless of which controller this is being called from.46 # This will render the partial "advertisement/_ad.erb" regardless of which controller this is being called from. 47 47 module Partials 48 48 # Deprecated, use render :partial trunk/actionpack/README
r6120 r6178 392 392 And the templates look like this: 393 393 394 weblog/layout. rhtml:394 weblog/layout.erb: 395 395 <html><body> 396 396 <%= yield %> 397 397 </body></html> 398 398 399 weblog/index. rhtml:399 weblog/index.erb: 400 400 <% for post in @posts %> 401 401 <p><%= link_to(post.title, :action => "display", :id => post.id %></p> 402 402 <% end %> 403 403 404 weblog/display. rhtml:404 weblog/display.erb: 405 405 <p> 406 406 <b><%= post.title %></b><br/> … … 408 408 </p> 409 409 410 weblog/new. rhtml:410 weblog/new.erb: 411 411 <%= form "post" %> 412 412 trunk/actionpack/test/controller/layout_test.rb
r6120 r6178 111 111 def test_rhtml_exempt_from_layout_status_should_prevent_layout_render 112 112 ActionController::Base.exempt_from_layout :rhtml 113 113 114 assert @controller.send(:template_exempt_from_layout?, 'test.rhtml') 115 assert @controller.send(:template_exempt_from_layout?, 'hello.rhtml') 114 116 115 117 get :hello trunk/actionpack/test/controller/new_render_test.rb
r6169 r6178 61 61 def render_file_with_instance_variables 62 62 @secret = 'in the sauce' 63 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar. rhtml')63 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb') 64 64 render :file => path 65 65 end 66 66 67 67 def render_file_with_locals 68 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals. rhtml')68 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb') 69 69 render :file => path, :locals => {:secret => 'in the sauce'} 70 70 end … … 228 228 229 229 def hello_world_from_rxml_using_action 230 render :action => "hello_world. rxml"230 render :action => "hello_world.builder" 231 231 end 232 232 233 233 def hello_world_from_rxml_using_template 234 render :template => "test/hello_world. rxml"234 render :template => "test/hello_world.builder" 235 235 end 236 236 trunk/actionpack/test/controller/rescue_test.rb
r5966 r6178 112 112 get :raises 113 113 assert_response :internal_server_error 114 assert_template 'diagnostics. rhtml'114 assert_template 'diagnostics.erb' 115 115 assert @response.body.include?('RescueController#raises'), "Response should include controller and action." 116 116 assert @response.body.include?("don't panic"), "Response should include exception message." trunk/actionpack/test/fixtures/addresses/list.rhtml
r1422 r6178 1 We only need to get this far!trunk/actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml
r5205 r6178 1 <%= @cookies[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml
r5205 r6178 1 <%= cookies[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml
r4824 r6178 1 <%= @flash[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_flash_method.rhtml
r4824 r6178 1 <%= flash[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml
r5206 r6178 1 <%= @headers[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_headers_method.rhtml
r5206 r6178 1 <%= headers[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml
r4824 r6178 1 <%= @params[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_params_method.rhtml
r4824 r6178 1 <%= params[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml
r5201 r6178 1 <%= @request.method %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_request_method.rhtml
r5201 r6178 1 <%= request.method %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml
r5207 r6178 1 <%= @response.body %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_response_method.rhtml
r5207 r6178 1 <%= response.body %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml
r4824 r6178 1 <%= @session[:test] %>trunk/actionpack/test/fixtures/deprecated_instance_variables/_session_method.rhtml
r4824 r6178 1 <%= session[:test] %>trunk/actionpack/test/fixtures/fun/games/hello_world.rhtml
r617 r6178 1 Living in a nested worldtrunk/actionpack/test/fixtures/layouts/builder.rxml
r4 r6178 1 xml.wrapper do2 xml << @content_for_layout3 endtrunk/actionpack/test/fixtures/layouts/standard.rhtml
r2777 r6178 1 <html><%= @content_for_layout %><%= @variable_for_layout %></html>trunk/actionpack/test/fixtures/layouts/talk_from_action.rhtml
r1911 r6178 1 <title><%= @title || @content_for_title %></title>2 <%= @content_for_layout -%>trunk/actionpack/test/fixtures/layouts/yield.rhtml
r2094 r6178 1 <title><%= yield :title %></title>2 <%= yield %>trunk/actionpack/test/fixtures/override/test/hello_world.rhtml
r6120 r6178 1 Hello overridden world!trunk/actionpack/test/fixtures/scope/test/modgreet.rhtml
r4 r6178 1 <p>Beautiful modules!</p>trunk/actionpack/test/fixtures/test/_customer_greeting.rhtml
r1941 r6178 1 <%= greeting %>: <%= customer_greeting.name %>trunk/actionpack/test/fixtures/test/_customer.rhtml
r1941 r6178 1 Hello: <%= customer.name %>trunk/actionpack/test/fixtures/test/_hash_object.rhtml
r2160 r6178 1 <%= hash_object[:first_name] %>trunk/actionpack/test/fixtures/test/_hello.rxml
r5044 r6178 1 xm.hellotrunk/actionpack/test/fixtures/test/_partial_only.rhtml
r1182 r6178 1 only partialtrunk/actionpack/test/fixtures/test/_person.rhtml
r1874 r6178 1 Second: <%= name %>2 Third: <%= @name %>trunk/actionpack/test/fixtures/test/action_talk_to_layout.rhtml
r1904 r6178 1 <% @title = "Talking to the layout" -%>2 Action was here!trunk/actionpack/test/fixtures/test/block_content_for.rhtml
r3669 r6178 1 <% block_content_for :title do 'Putting stuff in the title!' end %>2 Great stuff!trunk/actionpack/test/fixtures/test/capturing.rhtml
r1644 r6178 1 <% days = capture do %>2 Dreamy days3 <% end %>4 <%= days %>trunk/actionpack/test/fixtures/test/content_for.rhtml
r1911 r6178 1 <% content_for :title do %>Putting stuff in the title!<% end %>2 Great stuff!trunk/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.rhtml
r3884 r6178 1 The secret is <%= @secret %>trunk/actionpack/test/fixtures/test/erb_content_for.rhtml
r3669 r6178 1 <% erb_content_for :title do %>Putting stuff in the title!<% end %>2 Great stuff!trunk/actionpack/test/fixtures/test/greeting.rhtml
r4 r6178 1 <p>This is grand!</p>trunk/actionpack/test/fixtures/test/hello_world_container.rxml
r5044 r6178 1 xml.test do2 render :partial => 'hello', :locals => { :xm => xml }3 endtrunk/actionpack/test/fixtures/test/hello_world_with_layout_false.rhtml
r3321 r6178 1 Hello world!trunk/actionpack/test/fixtures/test/hello_world.rhtml
r4 r6178 1 Hello world!trunk/actionpack/test/fixtures/test/hello_world.rxml
r3841 r6178 1 xml.html do2 xml.p "Hello"3 endtrunk/actionpack/test/fixtures/test/hello_xml_world.rxml
r4 r6178 1 xml.html do2 xml.head do3 xml.title "Hello World"4 end5 6 xml.body do7 xml.p "abes"8 xml.p "monks"9 xml.p "wiseguys"10 end11 endtrunk/actionpack/test/fixtures/test/hello.rxml
r4 r6178 1 xml.html do2 xml.p "Hello #{@name}"3 xml << render_file("test/greeting")4 endtrunk/actionpack/test/fixtures/test/list.rhtml
r1717 r6178 1 <%= @test_unchanged = 'goodbye' %><%= render_collection_of_partials "customer", @customers %><%= @test_unchanged %>trunk/actionpack/test/fixtures/test/non_erb_block_content_for.rxml
r3669 r6178 1 content_for :title do2 'Putting stuff in the title!'3 end4 xml << "\nGreat stuff!"trunk/actionpack/test/fixtures/test/potential_conflicts.rhtml
r1874 r6178 1 First: <%= @name %>2 <%= render :partial => "person", :locals => { :name => "Stephan" } -%>3 Fourth: <%= @name %>4 Fifth: <%= name %>trunk/actionpack/test/fixtures/test/render_file_with_ivar.rhtml
r3157 r6178 1 The secret is <%= @secret %>trunk/actionpack/test/fixtures/test/render_file_with_locals.rhtml
r3157 r6178 1 The secret is <%= secret %>trunk/actionpack/test/fixtures/test/render_to_string_test.rhtml
r2723 r6178 1 The value of foo is: ::<%= @foo %>::trunk/actionpack/test/fixtures/test/update_element_with_capture.rhtml
r1665 r6178 1 <% replacement_function = update_element_function("products", :action => :update) do %>2 <p>Product 1</p>3 <p>Product 2</p>4 <% end %>5 <%= javascript_tag(replacement_function) %>6 7 <% update_element_function("status", :action => :update, :binding => binding) do %>8 <b>You bought something!</b>9 <% end %>