Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6178

Show
Ignore:
Timestamp:
02/20/07 22:09:12 (2 years ago)
Author:
david
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6164 r6178  
    11*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. 
    24 
    35* 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  
    7272  # Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action 
    7373  # 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. 
    7575  # 
    7676  # Unlike index, the sign action will not render a template. After performing its main purpose (creating a 
     
    663663      # The current layout is automatically applied. 
    664664      # 
    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
    666666      #   render :template => "weblog/show" 
    667667      # 
     
    672672      # 
    673673      #   # 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
    676676      # 
    677677      #   # Renders a template within the current layout, and with a 404 status code 
    678       #   render :file => "/path/to/some/template.rhtml", :layout => true, :status => 404 
    679       #   render :file => "c:/path/to/some/template.rhtml", :layout => true, :status => 404 
     678      #   render :file => "/path/to/some/template.erb", :layout => true, :status => 404 
     679      #   render :file => "c:/path/to/some/template.erb", :layout => true, :status => 404 
    680680      # 
    681681      #   # Renders a template relative to the template root and chooses the proper file extension 
     
    735735      # 
    736736      #   # Renders "<p>Good seeing you!</p>" using Builder 
    737       #   render :inline => "xml.p { 'Good seeing you!' }", :type => :rxml 
     737      #   render :inline => "xml.p { 'Good seeing you!' }", :type => :builder 
    738738      # 
    739739      #   # Renders "hello david" 
     
    864864      end 
    865865 
    866       def render_template(template, status = nil, type = :rhtml, local_assigns = {}) #:nodoc: 
     866      def render_template(template, status = nil, type = :erb, local_assigns = {}) #:nodoc: 
    867867        add_variables_to_assigns 
    868868        render_text(@template.render_template(type, template, nil, local_assigns), status) 
     
    12531253      def assert_existence_of_template_file(template_name) 
    12541254        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') 
    12561256          template_type = (template_name =~ /layouts/i) ? 'layout' : 'template' 
    12571257          raise(MissingTemplate, "Missing #{template_type} #{full_template_path}") 
  • trunk/actionpack/lib/action_controller/flash.rb

    r5021 r6178  
    1717  #   end 
    1818  # 
    19   #   display.rhtml 
     19  #   display.erb 
    2020  #     <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %> 
    2121  # 
  • trunk/actionpack/lib/action_controller/layout.rb

    r6120 r6178  
    6565    # If there is a template in <tt>app/views/layouts/</tt> with the same name as the current controller then it will be automatically 
    6666    # 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 as 
    68     # 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> 
    6969    # 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  
    7070    # 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>. 
    7272    # Setting a layout explicitly will always override the automatic behaviour for the controller where the layout is set. 
    7373    # 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  
    153153 
    154154      def rescues_path(template_name) 
    155         "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.rhtml
     155        "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.erb
    156156      end 
    157157 
  • trunk/actionpack/lib/action_controller/scaffolding.rb

    r4973 r6178  
    7272    #  end 
    7373    # 
    74     # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.rhtml" for 
     74    # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.erb" for 
    7575    # the show action) and if not, then render the generic template for that action. This gives you the possibility of using the 
    7676    # scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template 
     
    177177 
    178178            def scaffold_path(template_name) 
    179               File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".rhtml
     179              File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".erb
    180180            end 
    181181 
  • 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.clone 
    30   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 %> in 
    3   <%=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 = @exception 
    17    @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  
    55  end 
    66 
    7   # Action View templates can be written in three ways. If the template file has a +.rhtml+ extension then it uses a mixture of ERb  
    8   # (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.  
    99  # If the template file has a +.rjs+ extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator. 
    1010  #  
     
    7878  # 
    7979  # 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.  
    8181  # 
    8282  # Here are some basic examples: 
     
    247247      @first_render ||= template_path 
    248248      template_path_without_extension, template_extension = path_and_extension(template_path) 
    249        
    250249      if use_full_path 
    251250        if template_extension 
     
    281280        update_page(&block) 
    282281      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) 
    284283 
    285284        if options[:file] 
     
    295294    end 
    296295 
    297     # Renders the +template+ which is given as a string as either rhtml or rxml depending 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>. 
    298297    # The hash in <tt>local_assigns</tt> is made available as local variables. 
    299298    def render_template(template_extension, template, file_path = nil, local_assigns = {}) #:nodoc: 
     
    343342      @@template_handlers.find { |k,| template_exists?(template_path, k) } 
    344343    end 
    345  
     344     
     345    def one_of(template_path, *extensions)#:nodoc: 
     346      extensions.detect{|ext| template_exists?(template_path, ext)} 
     347    end 
     348     
    346349    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     
    350354    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     
    354359    def javascript_template_exists?(template_path)#:nodoc: 
    355360      template_exists?(template_path, :rjs) 
     
    362367      else 
    363368        cached_template_extension(template_path) || 
    364            %w(erb builder javascript delegate).any? do |template_type| 
     369           %w(erb rhtml builder rxml javascript delegate).any? do |template_type| 
    365370             send("#{template_type}_template_exists?", template_path) 
    366371           end 
     
    402407        if match = delegate_template_exists?(template_path) 
    403408          match.first.to_sym 
    404         elsif erb_template_exists?(template_path):        :rhtml 
    405         elsif builder_template_exists?(template_path):    :rxml 
     409        elsif extension = erb_template_exists?(template_path):        extension 
     410        elsif extension = builder_template_exists?(template_path):    extension 
    406411        elsif javascript_template_exists?(template_path): :rjs 
    407412        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}" 
    409414        end 
    410415      end 
     
    465470        if template_requires_setup?(extension) 
    466471          body = case extension.to_sym 
    467             when :rxml 
     472            when :rxml, :builder 
    468473              "controller.response.content_type ||= 'application/xml'\n" + 
    469474              "xml = Builder::XmlMarkup.new(:indent => 2)\n" + 
     
    494499 
    495500      def templates_requiring_setup 
    496         %w(rxml rjs) 
     501        %w(builder rxml rjs) 
    497502      end 
    498503 
     
    524529        if extension 
    525530          case extension.to_sym 
    526           when :rxml, :rjs 
     531          when :builder, :rxml, :rjs 
    527532            line_offset += 2 
    528533          end 
  • trunk/actionpack/lib/action_view/helpers/capture_helper.rb

    r5544 r6178  
    1515    # make the fragment available by name to a yielding layout or template. 
    1616    # 
    17     # layout.rhtml
     17    # layout.erb
    1818    # 
    1919    #   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
     
    2929    #   </html> 
    3030    # 
    31     # view.rhtml 
     31    # view.erb 
    3232    #    
    3333    #   This page shows an alert box! 
     
    4343      # in your templates and even in your layout.  
    4444      #  
    45       # Example of capture being used in a .rhtml page: 
     45      # Example of capture being used in a .erb page: 
    4646      #  
    4747      #   <% @greeting = capture do %> 
     
    4949      #   <% end %> 
    5050