Module: AbstractController::Rendering
- Extended by:
- ActiveSupport::Concern
- Includes:
- ViewPaths
- Included in:
- Helpers, Layouts, ActionController::Rendering
- Defined in:
- lib/abstract_controller/rendering.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#_prefix ⇒ Object
The prefix used in render “foo” shortcuts.
-
#_render_template(options) ⇒ Object
Find and renders a template based on the options given.
- #initialize ⇒ Object
-
#process ⇒ Object
Overwrite process to setup I18n proxy.
-
#render(*args, &block) ⇒ Object
Normalize arguments, options and then delegates render_to_body and sticks the result in self.response_body.
-
#render_to_body(options = {}) ⇒ Object
Raw rendering of a template to a Rack-compatible body.
-
#render_to_string(*args, &block) ⇒ Object
Raw rendering of a template to a string.
-
#view_context ⇒ Object
An instance of a view class.
Methods included from ViewPaths
#append_view_path, #details_for_lookup, #lookup_context, #prepend_view_path
Instance Attribute Details
#view_context_class ⇒ Object
67 68 69 |
# File 'lib/abstract_controller/rendering.rb', line 67 def view_context_class @view_context_class || self.class.view_context_class end |
Instance Method Details
#_prefix ⇒ Object
The prefix used in render “foo” shortcuts.
118 119 120 |
# File 'lib/abstract_controller/rendering.rb', line 118 def _prefix controller_path end |
#_render_template(options) ⇒ Object
Find and renders a template based on the options given. :api: private
113 114 115 |
# File 'lib/abstract_controller/rendering.rb', line 113 def _render_template() #:nodoc: view_context.render() end |
#initialize ⇒ Object
71 72 73 74 |
# File 'lib/abstract_controller/rendering.rb', line 71 def initialize(*) @view_context_class = nil super end |
#process ⇒ Object
Overwrite process to setup I18n proxy.
38 39 40 41 42 43 |
# File 'lib/abstract_controller/rendering.rb', line 38 def process(*) #:nodoc: old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context) super ensure I18n.config = old_config end |
#render(*args, &block) ⇒ Object
Normalize arguments, options and then delegates render_to_body and sticks the result in self.response_body.
91 92 93 |
# File 'lib/abstract_controller/rendering.rb', line 91 def render(*args, &block) self.response_body = render_to_string(*args, &block) end |
#render_to_body(options = {}) ⇒ Object
Raw rendering of a template to a Rack-compatible body. :api: plugin
106 107 108 109 |
# File 'lib/abstract_controller/rendering.rb', line 106 def render_to_body( = {}) () _render_template() end |
#render_to_string(*args, &block) ⇒ Object
Raw rendering of a template to a string. Just convert the results of render_to_body into a String. :api: plugin
98 99 100 101 102 |
# File 'lib/abstract_controller/rendering.rb', line 98 def render_to_string(*args, &block) = _normalize_args(*args, &block) () render_to_body() end |
#view_context ⇒ Object
An instance of a view class. The default view class is ActionView::Base
The view class must have the following methods: View.new[lookup_context, assigns, controller]
Create a new ActionView instance for a controller
Returns String with the rendered template
Override this method in a module to change the default behavior.
85 86 87 |
# File 'lib/abstract_controller/rendering.rb', line 85 def view_context view_context_class.new(lookup_context, view_assigns, self) end |