~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
module ActionView
2
 
  module Helpers
3
 
    # This helper to exposes a method for caching of view fragments.
4
 
    # See ActionController::Caching::Fragments for usage instructions.
5
 
    module CacheHelper
6
 
      # A method for caching fragments of a view rather than an entire
7
 
      # action or page.  This technique is useful caching pieces like
8
 
      # menus, lists of news topics, static HTML fragments, and so on.
9
 
      # This method takes a block that contains the content you wish
10
 
      # to cache.  See ActionController::Caching::Fragments for more
11
 
      # information.
12
 
      #
13
 
      # ==== Examples
14
 
      # If you wanted to cache a navigation menu, you could do the
15
 
      # following.
16
 
      #
17
 
      #   <% cache do %>
18
 
      #     <%= render :partial => "menu" %>
19
 
      #   <% end %>
20
 
      #
21
 
      # You can also cache static content...
22
 
      #
23
 
      #   <% cache do %>
24
 
      #      <p>Hello users!  Welcome to our website!</p>
25
 
      #   <% end %>
26
 
      #
27
 
      # ...and static content mixed with RHTML content.
28
 
      #
29
 
      #    <% cache do %>
30
 
      #      Topics:
31
 
      #      <%= render :partial => "topics", :collection => @topic_list %>
32
 
      #      <i>Topics listed alphabetically</i>
33
 
      #    <% end %>
34
 
      def cache(name = {}, options = nil, &block)
35
 
        @controller.fragment_for(output_buffer, name, options, &block)
36
 
      end
37
 
    end
38
 
  end
39
 
end