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.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6178 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
89cb34c9cf
commit
e105653066
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* 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.
|
||||
|
||||
* Added caching option to AssetTagHelper#stylesheet_link_tag and AssetTagHelper#javascript_include_tag [DHH]. Examples:
|
||||
|
||||
stylesheet_link_tag :all, :cache => true # when ActionController::Base.perform_caching is false =>
|
||||
|
@ -391,23 +391,23 @@ request from the web-server (like to be Apache).
|
||||
|
||||
And the templates look like this:
|
||||
|
||||
weblog/layout.rhtml:
|
||||
weblog/layout.erb:
|
||||
<html><body>
|
||||
<%= yield %>
|
||||
</body></html>
|
||||
|
||||
weblog/index.rhtml:
|
||||
weblog/index.erb:
|
||||
<% for post in @posts %>
|
||||
<p><%= link_to(post.title, :action => "display", :id => post.id %></p>
|
||||
<% end %>
|
||||
|
||||
weblog/display.rhtml:
|
||||
weblog/display.erb:
|
||||
<p>
|
||||
<b><%= post.title %></b><br/>
|
||||
<b><%= post.content %></b>
|
||||
</p>
|
||||
|
||||
weblog/new.rhtml:
|
||||
weblog/new.erb:
|
||||
<%= form "post" %>
|
||||
|
||||
This simple setup will list all the posts in the system on the index page,
|
||||
|
@ -1,33 +0,0 @@
|
||||
<h1>Address Book</h1>
|
||||
|
||||
<% if @people.empty? %>
|
||||
<p>No people in the address book yet</p>
|
||||
<% else %>
|
||||
<table>
|
||||
<tr><th>Name</th><th>Email Address</th><th>Phone Number</th></tr>
|
||||
<% for person in @people %>
|
||||
<tr><td><%= person.name %></td><td><%= person.email_address %></td><td><%= person.phone_number %></td></tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<form action="create_person">
|
||||
<p>
|
||||
Name:<br />
|
||||
<input type="text" name="person[name]">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Email address:<br />
|
||||
<input type="text" name="person[email_address]">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Phone number:<br />
|
||||
<input type="text" name="person[phone_number]">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Create Person">
|
||||
</p>
|
||||
</form>
|
@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title><%= @title || "Untitled" %></title>
|
||||
</head>
|
||||
<body>
|
||||
<%= @content_for_layout %>
|
||||
</body>
|
||||
</html>
|
@ -1,14 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>Topics</h1>
|
||||
|
||||
<%= link_to "New topic", :action => "new_topic" %>
|
||||
|
||||
<ul>
|
||||
<% for topic in @topics %>
|
||||
<li><%= link_to "#{topic.title} (#{topic.replies.length} replies)", :action => "topic", :path_params => { "id" => topic.id } %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>New topic</h1>
|
||||
|
||||
<form action="<%= url_for(:action => "create_topic") %>" method="post">
|
||||
<p>
|
||||
Title:<br>
|
||||
<input type="text" name="topic[title]">
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Body:<br>
|
||||
<textarea name="topic[body]" style="width: 200px; height: 200px"></textarea>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Create topic">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,32 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1><%= @topic.title %></h1>
|
||||
|
||||
<p><%= @topic.body %></p>
|
||||
|
||||
<%= link_to "Back to topics", :action => "index" %>
|
||||
|
||||
<% unless @topic.replies.empty? %>
|
||||
<h2>Replies</h2>
|
||||
<ol>
|
||||
<% for reply in @topic.replies %>
|
||||
<li><%= reply.body %></li>
|
||||
<% end %>
|
||||
</ol>
|
||||
<% end %>
|
||||
|
||||
<h2>Reply to this topic</h2>
|
||||
|
||||
<form action="<%= url_for(:action => "create_reply") %>" method="post">
|
||||
<input type="hidden" name="reply[topic_id]" value="<%= @topic.id %>">
|
||||
<p>
|
||||
<textarea name="reply[body]" style="width: 200px; height: 200px"></textarea>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Create reply">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -71,7 +71,7 @@ def initialize(message = nil)
|
||||
#
|
||||
# Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action
|
||||
# after executing code in the action. For example, the +index+ action of the +GuestBookController+ would render the
|
||||
# template <tt>app/views/guestbook/index.rhtml</tt> by default after populating the <tt>@entries</tt> instance variable.
|
||||
# template <tt>app/views/guestbook/index.erb</tt> by default after populating the <tt>@entries</tt> instance variable.
|
||||
#
|
||||
# Unlike index, the sign action will not render a template. After performing its main purpose (creating a
|
||||
# new entry in the guest book), it initiates a redirect instead. This redirect works by returning an external
|
||||
@ -662,7 +662,7 @@ def view_paths
|
||||
# Template rendering works just like action rendering except that it takes a path relative to the template root.
|
||||
# The current layout is automatically applied.
|
||||
#
|
||||
# # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show.rhtml)
|
||||
# # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show.erb)
|
||||
# render :template => "weblog/show"
|
||||
#
|
||||
# === Rendering a file
|
||||
@ -671,12 +671,12 @@ def view_paths
|
||||
# is assumed to be absolute, and the current layout is not applied.
|
||||
#
|
||||
# # Renders the template located at the absolute filesystem path
|
||||
# render :file => "/path/to/some/template.rhtml"
|
||||
# render :file => "c:/path/to/some/template.rhtml"
|
||||
# render :file => "/path/to/some/template.erb"
|
||||
# render :file => "c:/path/to/some/template.erb"
|
||||
#
|
||||
# # Renders a template within the current layout, and with a 404 status code
|
||||
# render :file => "/path/to/some/template.rhtml", :layout => true, :status => 404
|
||||
# render :file => "c:/path/to/some/template.rhtml", :layout => true, :status => 404
|
||||
# render :file => "/path/to/some/template.erb", :layout => true, :status => 404
|
||||
# render :file => "c:/path/to/some/template.erb", :layout => true, :status => 404
|
||||
#
|
||||
# # Renders a template relative to the template root and chooses the proper file extension
|
||||
# render :file => "some/template", :use_full_path => true
|
||||
@ -734,7 +734,7 @@ def view_paths
|
||||
# render :inline => "<%= 'hello, ' * 3 + 'again' %>"
|
||||
#
|
||||
# # Renders "<p>Good seeing you!</p>" using Builder
|
||||
# render :inline => "xml.p { 'Good seeing you!' }", :type => :rxml
|
||||
# render :inline => "xml.p { 'Good seeing you!' }", :type => :builder
|
||||
#
|
||||
# # Renders "hello david"
|
||||
# render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" }
|
||||
@ -863,7 +863,7 @@ def render_file(template_path, status = nil, use_full_path = false, locals = {})
|
||||
render_text(@template.render_file(template_path, use_full_path, locals), status)
|
||||
end
|
||||
|
||||
def render_template(template, status = nil, type = :rhtml, local_assigns = {}) #:nodoc:
|
||||
def render_template(template, status = nil, type = :erb, local_assigns = {}) #:nodoc:
|
||||
add_variables_to_assigns
|
||||
render_text(@template.render_template(type, template, nil, local_assigns), status)
|
||||
end
|
||||
@ -1252,7 +1252,7 @@ def template_exempt_from_layout?(template_name = default_template_name)
|
||||
|
||||
def assert_existence_of_template_file(template_name)
|
||||
unless template_exists?(template_name) || ignore_missing_templates
|
||||
full_template_path = @template.send(:full_template_path, template_name, 'rhtml')
|
||||
full_template_path = @template.send(:full_template_path, template_name, 'erb')
|
||||
template_type = (template_name =~ /layouts/i) ? 'layout' : 'template'
|
||||
raise(MissingTemplate, "Missing #{template_type} #{full_template_path}")
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ module ActionController #:nodoc:
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# display.rhtml
|
||||
# display.erb
|
||||
# <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %>
|
||||
#
|
||||
# This example just places a string in the flash, but you can put any object in there. And of course, you can put as many
|
||||
|
@ -64,11 +64,11 @@ class << self
|
||||
#
|
||||
# If there is a template in <tt>app/views/layouts/</tt> with the same name as the current controller then it will be automatically
|
||||
# set as that controller's layout unless explicitly told otherwise. Say you have a WeblogController, for example. If a template named
|
||||
# <tt>app/views/layouts/weblog.rhtml</tt> or <tt>app/views/layouts/weblog.rxml</tt> exists then it will be automatically set as
|
||||
# the layout for your WeblogController. You can create a layout with the name <tt>application.rhtml</tt> or <tt>application.rxml</tt>
|
||||
# <tt>app/views/layouts/weblog.erb</tt> or <tt>app/views/layouts/weblog.builder</tt> exists then it will be automatically set as
|
||||
# the layout for your WeblogController. You can create a layout with the name <tt>application.erb</tt> or <tt>application.builder</tt>
|
||||
# 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
|
||||
# no layout explicitly assigned with the +layout+ method. Nested controllers use the same folder structure for automatic layout.
|
||||
# assignment. So an Admin::WeblogController will look for a template named <tt>app/views/layouts/admin/weblog.rhtml</tt>.
|
||||
# assignment. So an Admin::WeblogController will look for a template named <tt>app/views/layouts/admin/weblog.erb</tt>.
|
||||
# Setting a layout explicitly will always override the automatic behaviour for the controller where the layout is set.
|
||||
# Explicitly setting the layout in a parent class, though, will not override the child class's layout assignement if the child
|
||||
# class has a layout with the same name.
|
||||
|
@ -152,7 +152,7 @@ def perform_action_with_rescue #:nodoc:
|
||||
end
|
||||
|
||||
def rescues_path(template_name)
|
||||
"#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.rhtml"
|
||||
"#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.erb"
|
||||
end
|
||||
|
||||
def template_path_for_local_rescue(exception)
|
||||
|
@ -71,7 +71,7 @@ def self.included(base)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.rhtml" for
|
||||
# The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.erb" for
|
||||
# the show action) and if not, then render the generic template for that action. This gives you the possibility of using the
|
||||
# scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template
|
||||
# and one action at a time while relying on the rest of the scaffolded templates and actions.
|
||||
@ -176,7 +176,7 @@ def render#{suffix}_scaffold(action=nil)
|
||||
end
|
||||
|
||||
def scaffold_path(template_name)
|
||||
File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".rhtml"
|
||||
File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".erb"
|
||||
end
|
||||
|
||||
def caller_method_name(caller)
|
||||
|
@ -1,44 +0,0 @@
|
||||
<% unless @exception.blamed_files.blank? %>
|
||||
<% if (hide = @exception.blamed_files.length > 8) %>
|
||||
<a href="#" onclick="document.getElementById('blame_trace').style.display='block'; return false;">Show blamed files</a>
|
||||
<% end %>
|
||||
<pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre>
|
||||
<% end %>
|
||||
|
||||
<% if false %>
|
||||
<br /><br />
|
||||
<% begin %>
|
||||
<%= form_tag(request.request_uri, "method" => request.method) %>
|
||||
<input type="hidden" name="BP-RETRY" value="1" />
|
||||
|
||||
<% for key, values in params %>
|
||||
<% next if key == "BP-RETRY" %>
|
||||
<% for value in Array(values) %>
|
||||
<input type="hidden" name="<%= key %>" value="<%= value %>" />
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<input type="submit" value="Retry with Breakpoint" />
|
||||
</form>
|
||||
<% rescue Exception => e %>
|
||||
<%=h "Couldn't render breakpoint link due to #{e.class} #{e.message}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%
|
||||
clean_params = request.parameters.clone
|
||||
clean_params.delete("action")
|
||||
clean_params.delete("controller")
|
||||
|
||||
request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n")
|
||||
%>
|
||||
|
||||
<h2 style="margin-top: 30px">Request</h2>
|
||||
<p><b>Parameters</b>: <pre><%=h request_dump %></pre></p>
|
||||
|
||||
<p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>
|
||||
<div id="session_dump" style="display:none"><%= debug(request.session.instance_variable_get("@data")) %></div>
|
||||
|
||||
|
||||
<h2 style="margin-top: 30px">Response</h2>
|
||||
<p><b>Headers</b>: <pre><%=h response ? response.headers.inspect.gsub(',', ",\n") : 'None' %></pre></p>
|
@ -1,26 +0,0 @@
|
||||
<%
|
||||
traces = [
|
||||
["Application Trace", @exception.application_backtrace],
|
||||
["Framework Trace", @exception.framework_backtrace],
|
||||
["Full Trace", @exception.clean_backtrace]
|
||||
]
|
||||
names = traces.collect {|name, trace| name}
|
||||
%>
|
||||
|
||||
<p><code>RAILS_ROOT: <%= defined?(RAILS_ROOT) ? RAILS_ROOT : "unset" %></code></p>
|
||||
|
||||
<div id="traces">
|
||||
<% names.each do |name| -%>
|
||||
<%
|
||||
show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';"
|
||||
hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"}
|
||||
%>
|
||||
<a href="#" onclick="<%= hide %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
|
||||
<% end -%>
|
||||
|
||||
<% traces.each do |name, trace| -%>
|
||||
<div id="<%= name.gsub /\s/, '-' %>" style="display: <%= name == "Application Trace" ? 'block' : 'none' %>;">
|
||||
<pre><code><%= trace.join "\n" %></code></pre>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
@ -1,11 +0,0 @@
|
||||
<h1>
|
||||
<%=h @exception.class.to_s %>
|
||||
<% if request.parameters['controller'] %>
|
||||
in <%=h request.parameters['controller'].humanize %>Controller<% if request.parameters['action'] %>#<%=h request.parameters['action'] %><% end %>
|
||||
<% end %>
|
||||
</h1>
|
||||
<pre><%=h @exception.clean_message %></pre>
|
||||
|
||||
<%= render_file(@rescues_path + "/_trace.rhtml", false) %>
|
||||
|
||||
<%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %>
|
@ -1,29 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Action Controller: Exception caught</title>
|
||||
<style>
|
||||
body { background-color: #fff; color: #333; }
|
||||
|
||||
body, p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a { color: #000; }
|
||||
a:visited { color: #666; }
|
||||
a:hover { color: #fff; background-color:#000; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%= @contents %>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,2 +0,0 @@
|
||||
<h1>Template is missing</h1>
|
||||
<p><%=h @exception.message %></p>
|
@ -1,10 +0,0 @@
|
||||
<h1>Routing Error</h1>
|
||||
<p><pre><%=h @exception.message %></pre></p>
|
||||
<% unless @exception.failures.empty? %><p>
|
||||
<h2>Failure reasons:</h2>
|
||||
<ol>
|
||||
<% @exception.failures.each do |route, reason| %>
|
||||
<li><code><%=h route.inspect.gsub('\\', '') %></code> failed because <%=h reason.downcase %></li>
|
||||
<% end %>
|
||||
</ol>
|
||||
</p><% end %>
|
@ -1,21 +0,0 @@
|
||||
<h1>
|
||||
<%=h @exception.original_exception.class.to_s %> in
|
||||
<%=h request.parameters["controller"].capitalize if request.parameters["controller"]%>#<%=h request.parameters["action"] %>
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised:
|
||||
<pre><code><%=h @exception.message %></code></pre>
|
||||
</p>
|
||||
|
||||
<p>Extracted source (around line <b>#<%=h @exception.line_number %></b>):
|
||||
<pre><code><%=h @exception.source_extract %></code></pre></p>
|
||||
|
||||
<p><%=h @exception.sub_template_message %></p>
|
||||
|
||||
<% @real_exception = @exception
|
||||
@exception = @exception.original_exception || @exception %>
|
||||
<%= render_file(@rescues_path + "/_trace.rhtml", false) %>
|
||||
<% @exception = @real_exception %>
|
||||
|
||||
<%= render_file(@rescues_path + "/_request_and_response.rhtml", false) %>
|
@ -1,2 +0,0 @@
|
||||
<h1>Unknown action</h1>
|
||||
<p><%=h @exception.message %></p>
|
@ -1,7 +0,0 @@
|
||||
<h1>Editing <%= @scaffold_singular_name %></h1>
|
||||
|
||||
<%= error_messages_for(@scaffold_singular_name) %>
|
||||
<%= form(@scaffold_singular_name, :action => "update#{@scaffold_suffix}") %>
|
||||
|
||||
<%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |
|
||||
<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
|
@ -1,69 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Scaffolding</title>
|
||||
<style>
|
||||
body { background-color: #fff; color: #333; }
|
||||
|
||||
body, p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a { color: #000; }
|
||||
a:visited { color: #666; }
|
||||
a:hover { color: #fff; background-color:#000; }
|
||||
|
||||
.fieldWithErrors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#errorExplanation {
|
||||
width: 400px;
|
||||
border: 2px solid red;
|
||||
padding: 7px;
|
||||
padding-bottom: 12px;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
#errorExplanation h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#errorExplanation p {
|
||||
color: #333;
|
||||
margin-bottom: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#errorExplanation ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p style="color: green"><%= flash[:notice] %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,27 +0,0 @@
|
||||
<h1>Listing <%= @scaffold_plural_name %></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<% for column in @scaffold_class.content_columns %>
|
||||
<th><%= column.human_name %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>
|
||||
<tr>
|
||||
<% for column in @scaffold_class.content_columns %>
|
||||
<td><%= entry.send(column.name) %></td>
|
||||
<% end %>
|
||||
<td><%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %></td>
|
||||
<td><%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %></td>
|
||||
<td><%= link_to "Destroy", {:action => "destroy#{@scaffold_suffix}", :id => entry}, { :confirm => "Are you sure?", :method => :post } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= link_to "Previous page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous %>
|
||||
<%= link_to "Next page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.next } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.next %>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to "New #{@scaffold_singular_name}", :action => "new#{@scaffold_suffix}" %>
|
@ -1,6 +0,0 @@
|
||||
<h1>New <%= @scaffold_singular_name %></h1>
|
||||
|
||||
<%= error_messages_for(@scaffold_singular_name) %>
|
||||
<%= form(@scaffold_singular_name, :action => "create#{@scaffold_suffix}") %>
|
||||
|
||||
<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
|
@ -1,9 +0,0 @@
|
||||
<% for column in @scaffold_class.content_columns %>
|
||||
<p>
|
||||
<b><%= column.human_name %>:</b>
|
||||
<%= instance_variable_get("@#{@scaffold_singular_name}").send(column.name) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |
|
||||
<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
|
@ -4,8 +4,8 @@ module ActionView #:nodoc:
|
||||
class ActionViewError < StandardError #:nodoc:
|
||||
end
|
||||
|
||||
# Action View templates can be written in three ways. If the template file has a +.rhtml+ extension then it uses a mixture of ERb
|
||||
# (included in Ruby) and HTML. If the template file has a +.rxml+ extension then Jim Weirich's Builder::XmlMarkup library is used.
|
||||
# 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
|
||||
# (included in Ruby) and HTML. If the template file has a +.builder+ (or +.rxml+) extension then Jim Weirich's Builder::XmlMarkup library is used.
|
||||
# If the template file has a +.rjs+ extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.
|
||||
#
|
||||
# = ERb
|
||||
@ -77,7 +77,7 @@ class ActionViewError < StandardError #:nodoc:
|
||||
# == Builder
|
||||
#
|
||||
# Builder templates are a more programmatic alternative to ERb. They are especially useful for generating XML content. An +XmlMarkup+ object
|
||||
# named +xml+ is automatically made available to templates with a +.rxml+ extension.
|
||||
# named +xml+ is automatically made available to templates with a +.builder+ extension.
|
||||
#
|
||||
# Here are some basic examples:
|
||||
#
|
||||
@ -246,7 +246,6 @@ def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)
|
||||
def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc:
|
||||
@first_render ||= template_path
|
||||
template_path_without_extension, template_extension = path_and_extension(template_path)
|
||||
|
||||
if use_full_path
|
||||
if template_extension
|
||||
template_file_name = full_template_path(template_path_without_extension, template_extension)
|
||||
@ -280,7 +279,7 @@ def render(options = {}, old_local_assigns = {}, &block) #:nodoc:
|
||||
elsif options == :update
|
||||
update_page(&block)
|
||||
elsif options.is_a?(Hash)
|
||||
options = options.reverse_merge(:type => :rhtml, :locals => {}, :use_full_path => true)
|
||||
options = options.reverse_merge(:type => :erb, :locals => {}, :use_full_path => true)
|
||||
|
||||
if options[:file]
|
||||
render_file(options[:file], options[:use_full_path], options[:locals])
|
||||
@ -294,7 +293,7 @@ def render(options = {}, old_local_assigns = {}, &block) #:nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
# Renders the +template+ which is given as a string as either rhtml or rxml depending on <tt>template_extension</tt>.
|
||||
# Renders the +template+ which is given as a string as either erb or builder depending on <tt>template_extension</tt>.
|
||||
# The hash in <tt>local_assigns</tt> is made available as local variables.
|
||||
def render_template(template_extension, template, file_path = nil, local_assigns = {}) #:nodoc:
|
||||
if handler = @@template_handlers[template_extension]
|
||||
@ -342,15 +341,21 @@ def pick_template_extension(template_path)#:nodoc:
|
||||
def delegate_template_exists?(template_path)#:nodoc:
|
||||
@@template_handlers.find { |k,| template_exists?(template_path, k) }
|
||||
end
|
||||
|
||||
|
||||
def one_of(template_path, *extensions)#:nodoc:
|
||||
extensions.detect{|ext| template_exists?(template_path, ext)}
|
||||
end
|
||||
|
||||
def erb_template_exists?(template_path)#:nodoc:
|
||||
template_exists?(template_path, :rhtml)
|
||||
one_of(template_path, :erb, :rhtml)
|
||||
end
|
||||
|
||||
alias :rhtml_template_exists? :erb_template_exists?
|
||||
|
||||
def builder_template_exists?(template_path)#:nodoc:
|
||||
template_exists?(template_path, :rxml)
|
||||
one_of(template_path, :builder, :rxml)
|
||||
end
|
||||
|
||||
alias :rxml_template_exists? :builder_template_exists?
|
||||
|
||||
def javascript_template_exists?(template_path)#:nodoc:
|
||||
template_exists?(template_path, :rjs)
|
||||
end
|
||||
@ -361,7 +366,7 @@ def file_exists?(template_path)#:nodoc:
|
||||
template_exists?(template_file_name, template_file_extension)
|
||||
else
|
||||
cached_template_extension(template_path) ||
|
||||
%w(erb builder javascript delegate).any? do |template_type|
|
||||
%w(erb rhtml builder rxml javascript delegate).any? do |template_type|
|
||||
send("#{template_type}_template_exists?", template_path)
|
||||
end
|
||||
end
|
||||
@ -401,11 +406,11 @@ def find_base_path_for(template_file_name)
|
||||
def find_template_extension_for(template_path)
|
||||
if match = delegate_template_exists?(template_path)
|
||||
match.first.to_sym
|
||||
elsif erb_template_exists?(template_path): :rhtml
|
||||
elsif builder_template_exists?(template_path): :rxml
|
||||
elsif extension = erb_template_exists?(template_path): extension
|
||||
elsif extension = builder_template_exists?(template_path): extension
|
||||
elsif javascript_template_exists?(template_path): :rjs
|
||||
else
|
||||
raise ActionViewError, "No rhtml, rxml, rjs or delegate template found for #{template_path} in #{@view_paths.inspect}"
|
||||
raise ActionViewError, "No erb, builder, rhtml, rxml, rjs or delegate template found for #{template_path} in #{@view_paths.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -464,7 +469,7 @@ def template_changed_since?(file_name, compile_time)
|
||||
def create_template_source(extension, template, render_symbol, locals)
|
||||
if template_requires_setup?(extension)
|
||||
body = case extension.to_sym
|
||||
when :rxml
|
||||
when :rxml, :builder
|
||||
"controller.response.content_type ||= 'application/xml'\n" +
|
||||
"xml = Builder::XmlMarkup.new(:indent => 2)\n" +
|
||||
template
|
||||
@ -493,7 +498,7 @@ def template_requires_setup?(extension)
|
||||
end
|
||||
|
||||
def templates_requiring_setup
|
||||
%w(rxml rjs)
|
||||
%w(builder rxml rjs)
|
||||
end
|
||||
|
||||
def assign_method_name(extension, template, file_name)
|
||||
@ -523,7 +528,7 @@ def compile_template(extension, template, file_name, local_assigns)
|
||||
line_offset = @@template_args[render_symbol].size
|
||||
if extension
|
||||
case extension.to_sym
|
||||
when :rxml, :rjs
|
||||
when :builder, :rxml, :rjs
|
||||
line_offset += 2
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module Helpers
|
||||
# content_for("name") is a wrapper for capture which will
|
||||
# make the fragment available by name to a yielding layout or template.
|
||||
#
|
||||
# layout.rhtml:
|
||||
# layout.erb:
|
||||
#
|
||||
# <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
# <head>
|
||||
@ -28,7 +28,7 @@ module Helpers
|
||||
# </body>
|
||||
# </html>
|
||||
#
|
||||
# view.rhtml
|
||||
# view.erb
|
||||
#
|
||||
# This page shows an alert box!
|
||||
#
|
||||
@ -42,13 +42,13 @@ module CaptureHelper
|
||||
# instance variable. You can use this instance variable anywhere
|
||||
# in your templates and even in your layout.
|
||||
#
|
||||
# Example of capture being used in a .rhtml page:
|
||||
# Example of capture being used in a .erb page:
|
||||
#
|
||||
# <% @greeting = capture do %>
|
||||
# Welcome To my shiny new web page!
|
||||
# <% end %>
|
||||
#
|
||||
# Example of capture being used in a .rxml page:
|
||||
# Example of capture being used in a .builder page:
|
||||
#
|
||||
# @greeting = capture do
|
||||
# 'Welcome To my shiny new web page!'
|
||||
|
@ -7,7 +7,7 @@ module ActionView
|
||||
#
|
||||
# <%= render :partial => "account" %>
|
||||
#
|
||||
# This would render "advertiser/_account.rhtml" and pass the instance variable @account in as a local variable +account+ to
|
||||
# This would render "advertiser/_account.erb" and pass the instance variable @account in as a local variable +account+ to
|
||||
# the template for display.
|
||||
#
|
||||
# In another template for Advertiser#buy, we could have:
|
||||
@ -18,8 +18,8 @@ module ActionView
|
||||
# <%= render :partial => "ad", :locals => { :ad => ad } %>
|
||||
# <% end %>
|
||||
#
|
||||
# This would first render "advertiser/_account.rhtml" with @buyer passed in as the local variable +account+, then render
|
||||
# "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display.
|
||||
# This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then render
|
||||
# "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display.
|
||||
#
|
||||
# == Rendering a collection of partials
|
||||
#
|
||||
@ -30,7 +30,7 @@ module ActionView
|
||||
#
|
||||
# <%= render :partial => "ad", :collection => @advertisements %>
|
||||
#
|
||||
# This will render "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display. An iteration counter
|
||||
# This will render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display. An iteration counter
|
||||
# will automatically be made available to the template with a name of the form +partial_name_counter+. In the case of the
|
||||
# example above, the template would be fed +ad_counter+.
|
||||
#
|
||||
@ -43,7 +43,7 @@ module ActionView
|
||||
#
|
||||
# <%= render :partial => "advertisement/ad", :locals => { :ad => @advertisement } %>
|
||||
#
|
||||
# This will render the partial "advertisement/_ad.rhtml" regardless of which controller this is being called from.
|
||||
# This will render the partial "advertisement/_ad.erb" regardless of which controller this is being called from.
|
||||
module Partials
|
||||
# Deprecated, use render :partial
|
||||
def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
|
||||
|
@ -110,7 +110,9 @@ def test_add_regexp_to_exempt_from_layout
|
||||
|
||||
def test_rhtml_exempt_from_layout_status_should_prevent_layout_render
|
||||
ActionController::Base.exempt_from_layout :rhtml
|
||||
|
||||
assert @controller.send(:template_exempt_from_layout?, 'test.rhtml')
|
||||
assert @controller.send(:template_exempt_from_layout?, 'hello.rhtml')
|
||||
|
||||
get :hello
|
||||
assert_equal 'hello.rhtml', @response.body
|
||||
|
@ -60,12 +60,12 @@ def render_custom_code
|
||||
|
||||
def render_file_with_instance_variables
|
||||
@secret = 'in the sauce'
|
||||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.rhtml')
|
||||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')
|
||||
render :file => path
|
||||
end
|
||||
|
||||
def render_file_with_locals
|
||||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.rhtml')
|
||||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')
|
||||
render :file => path, :locals => {:secret => 'in the sauce'}
|
||||
end
|
||||
|
||||
@ -227,11 +227,11 @@ def @template.name() nil end
|
||||
end
|
||||
|
||||
def hello_world_from_rxml_using_action
|
||||
render :action => "hello_world.rxml"
|
||||
render :action => "hello_world.builder"
|
||||
end
|
||||
|
||||
def hello_world_from_rxml_using_template
|
||||
render :template => "test/hello_world.rxml"
|
||||
render :template => "test/hello_world.builder"
|
||||
end
|
||||
|
||||
def head_with_location_header
|
||||
|
@ -111,7 +111,7 @@ def test_rescue_unknown_action_in_public_without_error_file
|
||||
def test_rescue_action_locally
|
||||
get :raises
|
||||
assert_response :internal_server_error
|
||||
assert_template 'diagnostics.rhtml'
|
||||
assert_template 'diagnostics.erb'
|
||||
assert @response.body.include?('RescueController#raises'), "Response should include controller and action."
|
||||
assert @response.body.include?("don't panic"), "Response should include exception message."
|
||||
end
|
||||
|
@ -1 +0,0 @@
|
||||
We only need to get this far!
|
@ -1 +0,0 @@
|
||||
<%= @cookies[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= cookies[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= @flash[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= flash[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= @headers[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= headers[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= @params[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= params[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= @request.method %>
|
@ -1 +0,0 @@
|
||||
<%= request.method %>
|
@ -1 +0,0 @@
|
||||
<%= @response.body %>
|
@ -1 +0,0 @@
|
||||
<%= response.body %>
|
@ -1 +0,0 @@
|
||||
<%= @session[:test] %>
|
@ -1 +0,0 @@
|
||||
<%= session[:test] %>
|
@ -1 +0,0 @@
|
||||
Living in a nested world
|
@ -1,3 +0,0 @@
|
||||
xml.wrapper do
|
||||
xml << @content_for_layout
|
||||
end
|
@ -1 +0,0 @@
|
||||
<html><%= @content_for_layout %><%= @variable_for_layout %></html>
|
@ -1,2 +0,0 @@
|
||||
<title><%= @title || @content_for_title %></title>
|
||||
<%= @content_for_layout -%>
|
2
actionpack/test/fixtures/layouts/yield.rhtml
vendored
2
actionpack/test/fixtures/layouts/yield.rhtml
vendored
@ -1,2 +0,0 @@
|
||||
<title><%= yield :title %></title>
|
||||
<%= yield %>
|
@ -1 +0,0 @@
|
||||
Hello overridden world!
|
@ -1 +0,0 @@
|
||||
<p>Beautiful modules!</p>
|
@ -1 +0,0 @@
|
||||
Hello: <%= customer.name %>
|
@ -1 +0,0 @@
|
||||
<%= greeting %>: <%= customer_greeting.name %>
|
@ -1 +0,0 @@
|
||||
<%= hash_object[:first_name] %>
|
1
actionpack/test/fixtures/test/_hello.rxml
vendored
1
actionpack/test/fixtures/test/_hello.rxml
vendored
@ -1 +0,0 @@
|
||||
xm.hello
|
@ -1 +0,0 @@
|
||||
only partial
|
2
actionpack/test/fixtures/test/_person.rhtml
vendored
2
actionpack/test/fixtures/test/_person.rhtml
vendored
@ -1,2 +0,0 @@
|
||||
Second: <%= name %>
|
||||
Third: <%= @name %>
|
@ -1,2 +0,0 @@
|
||||
<% @title = "Talking to the layout" -%>
|
||||
Action was here!
|
@ -1,2 +0,0 @@
|
||||
<% block_content_for :title do 'Putting stuff in the title!' end %>
|
||||
Great stuff!
|
@ -1,4 +0,0 @@
|
||||
<% days = capture do %>
|
||||
Dreamy days
|
||||
<% end %>
|
||||
<%= days %>
|
@ -1,2 +0,0 @@
|
||||
<% content_for :title do %>Putting stuff in the title!<% end %>
|
||||
Great stuff!
|
@ -1 +0,0 @@
|
||||
The secret is <%= @secret %>
|
@ -1,2 +0,0 @@
|
||||
<% erb_content_for :title do %>Putting stuff in the title!<% end %>
|
||||
Great stuff!
|
1
actionpack/test/fixtures/test/greeting.rhtml
vendored
1
actionpack/test/fixtures/test/greeting.rhtml
vendored
@ -1 +0,0 @@
|
||||
<p>This is grand!</p>
|
4
actionpack/test/fixtures/test/hello.rxml
vendored
4
actionpack/test/fixtures/test/hello.rxml
vendored
@ -1,4 +0,0 @@
|
||||
xml.html do
|
||||
xml.p "Hello #{@name}"
|
||||
xml << render_file("test/greeting")
|
||||
end
|
@ -1 +0,0 @@
|
||||
Hello world!
|
@ -1,3 +0,0 @@
|
||||
xml.html do
|
||||
xml.p "Hello"
|
||||
end
|
@ -1,3 +0,0 @@
|
||||
xml.test do
|
||||
render :partial => 'hello', :locals => { :xm => xml }
|
||||
end
|
@ -1 +0,0 @@
|
||||
Hello world!
|
@ -1,11 +0,0 @@
|
||||
xml.html do
|
||||
xml.head do
|
||||
xml.title "Hello World"
|
||||
end
|
||||
|
||||
xml.body do
|
||||
xml.p "abes"
|
||||
xml.p "monks"
|
||||
xml.p "wiseguys"
|
||||
end
|
||||
end
|
1
actionpack/test/fixtures/test/list.rhtml
vendored
1
actionpack/test/fixtures/test/list.rhtml
vendored
@ -1 +0,0 @@
|
||||
<%= @test_unchanged = 'goodbye' %><%= render_collection_of_partials "customer", @customers %><%= @test_unchanged %>
|
@ -1,4 +0,0 @@
|
||||
content_for :title do
|
||||
'Putting stuff in the title!'
|
||||
end
|
||||
xml << "\nGreat stuff!"
|
@ -1,4 +0,0 @@
|
||||
First: <%= @name %>
|
||||
<%= render :partial => "person", :locals => { :name => "Stephan" } -%>
|
||||
Fourth: <%= @name %>
|
||||
Fifth: <%= name %>
|
@ -1 +0,0 @@
|
||||
The secret is <%= @secret %>
|
@ -1 +0,0 @@
|
||||
The secret is <%= secret %>
|
@ -1 +0,0 @@
|
||||
The value of foo is: ::<%= @foo %>::
|
@ -1,9 +0,0 @@
|
||||
<% replacement_function = update_element_function("products", :action => :update) do %>
|
||||
<p>Product 1</p>
|
||||
<p>Product 2</p>
|
||||
<% end %>
|
||||
<%= javascript_tag(replacement_function) %>
|
||||
|
||||
<% update_element_function("status", :action => :update, :binding => binding) do %>
|
||||
<b>You bought something!</b>
|
||||
<% end %>
|
Loading…
Reference in New Issue
Block a user