# encoding: utf-8 # These Methods are automatically added to all Controllers and Views when # the cells plugin is loaded. module Cells module Rails module ActionController # Equivalent to ActionController#render_to_string, except it renders a cell # rather than a regular templates. def render_cell(name, state, opts={}) ::Cell::Base.render_cell_for(self, name, state, opts) end # Expires the cached cell state view, similar to ActionController::expire_fragment. # Usually, this method is used in Sweepers. # Beside the obvious first two args cell_name and state you can pass # in additional cache key args and cache store specific opts. # # Example: # # class ListSweeper < ActionController::Caching::Sweeper # observe List, Item # # def after_save(record) # expire_cell_state :my_listing, :display_list # end # # will expire the view for state :display_list in the cell MyListingCell. def expire_cell_state(cell_name, state, args={}, opts=nil) key = ::Cell::Base.cache_key_for(cell_name, state, args) ::Cell::Base.expire_cache_key(key, opts) end end module ActionView # Call a cell state and return its rendered view. # # ERB example: #