aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/layouts_and_rendering.textile
diff options
context:
space:
mode:
authorJoseph Pecoraro <joepeck02@gmail.com>2009-05-29 09:53:33 -0400
committerJoseph Pecoraro <joepeck02@gmail.com>2009-05-29 09:53:33 -0400
commitd2b8564ab213d0b63790297f29696a277812eea5 (patch)
tree1cf3c72152f56d8167bb14bd0cc7efd447358a5c /railties/guides/source/layouts_and_rendering.textile
parent9c0064dd981be9e09df2e902550d0e0ce3e0d30b (diff)
downloadrails-d2b8564ab213d0b63790297f29696a277812eea5.tar.gz
rails-d2b8564ab213d0b63790297f29696a277812eea5.tar.bz2
rails-d2b8564ab213d0b63790297f29696a277812eea5.zip
Typo and Style Corrections
Diffstat (limited to 'railties/guides/source/layouts_and_rendering.textile')
-rw-r--r--railties/guides/source/layouts_and_rendering.textile34
1 files changed, 17 insertions, 17 deletions
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index feeddfa346..e1b259bea7 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -204,7 +204,7 @@ TIP: You don't need to call +to_xml+ on the object that you want to render. If y
h5. Rendering Vanilla JavaScript
-Rails can render vanilla JavaScript (as an alternative to using +update+ with n +.rjs+ file):
+Rails can render vanilla JavaScript (as an alternative to using +update+ with an +.rjs+ file):
<ruby>
render :js => "alert('Hello Rails');"
@@ -266,7 +266,7 @@ render :xml => photo, :location => photo_url(photo)
h5. Finding Layouts
-To find the current layout, Rails first looks for a file in +app/views/layouts+ with the same base name as the controller. For example, rendering actions from the +PhotosController+ class will use +app/views/layouts/photos.html.erb+ (or +app/views/layouts/photos.builder+). If there is no such controller-specific layout, Rails will use +app/views/layouts/application.html.erb+ ot +app/views/layouts/application.builder+. If there is no +.erb+ layout, Rails will use a +.builder+ layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions.
+To find the current layout, Rails first looks for a file in +app/views/layouts+ with the same base name as the controller. For example, rendering actions from the +PhotosController+ class will use +app/views/layouts/photos.html.erb+ (or +app/views/layouts/photos.builder+). If there is no such controller-specific layout, Rails will use +app/views/layouts/application.html.erb+ or +app/views/layouts/application.builder+. If there is no +.erb+ layout, Rails will use a +.builder+ layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions.
h6. Specifying Layouts on a per-Controller Basis
@@ -421,12 +421,12 @@ end
Note that the implicit render done by ActionController detects if +render+ has been called, and thus avoids this error. So this code will work with problems:
<ruby>
- def show
- @book = Book.find(params[:id])
- if @book.special?
- render :action => "special_show"
- end
+def show
+ @book = Book.find(params[:id])
+ if @book.special?
+ render :action => "special_show"
end
+end
</ruby>
This will render a book with +special?+ set with the +special_show+ template, while other books will render with the default +show+ template.
@@ -519,10 +519,10 @@ h4. Asset Tags
Asset tags provide methods for generating HTML that links views to assets like images, javascript, stylesheets, and feeds. There are four types of include tag:
-* auto_discovery_link_tag
-* javascript_include_tag
-* stylesheet_link_tag
-* image_tag
+* +auto_discovery_link_tag+
+* +javascript_include_tag+
+* +stylesheet_link_tag+
+* +image_tag+
You can use these tags in layouts or other views, although the tags other than +image_tag+ are most commonly used in the +&lt;head&gt;+ section of a layout.
@@ -622,16 +622,16 @@ To include +public/stylesheets/main.css+ and +public/photos/columns.css+:
<%= stylesheet_link_tag "main", "/photos/columns" %>
</erb>
-To include +http://example.com/main.cs+:
+To include +http://example.com/main.css+:
<erb>
-<%= stylesheet_link_tag "http://example.com/main.cs" %>
+<%= stylesheet_link_tag "http://example.com/main.css" %>
</erb>
-By default, +stylesheet_link_tag+ creates links with +media="screen" rel="stylesheet" type="text/css"+. You can override any of these defaults by specifying an appropriate option (:media, :rel, or :type):
+By default, +stylesheet_link_tag+ creates links with +media="screen" rel="stylesheet" type="text/css"+. You can override any of these defaults by specifying an appropriate option (+:media+, +:rel+, or +:type+):
<erb>
-<%= stylesheet_link_tag "main_print", media => "print" %>
+<%= stylesheet_link_tag "main_print", :media => "print" %>
</erb>
The +all+ option links every CSS file in +public/stylesheets+:
@@ -958,13 +958,13 @@ On pages generated by +NewsController+, you want to hide the top menu and add a
<% content_for :content do %>
<div id="right_menu">Right menu items here</div>
<%= yield(:news_content) or yield %>
- <% end -%>
+<% end -%>
<%= render :file => 'layouts/application' %>
</erb>
That's it. The News views will use the new layout, hiding the top menu and adding a new right menu inside the "content" div.
-There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render :file => 'layouts/news'+ to base a new layout on the News layout. If one is sure she will not subtemplate the +News+ layout, she can ommit the +yield(:news_content) or + part.
+There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render :file => 'layouts/news'+ to base a new layout on the News layout. If one is sure she will not subtemplate the +News+ layout, she can omit the +yield(:news_content) or + part.
h3. Changelog