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
68 69 70 |
# File 'lib/abstract_controller/rendering.rb', line 68 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.
119 120 121 |
# File 'lib/abstract_controller/rendering.rb', line 119 def _prefix controller_path end |
#_render_template(options) ⇒ Object
Find and renders a template based on the options given. :api: private
114 115 116 |
# File 'lib/abstract_controller/rendering.rb', line 114 def _render_template() #:nodoc: view_context.render() end |
#initialize ⇒ Object
72 73 74 75 |
# File 'lib/abstract_controller/rendering.rb', line 72 def initialize(*) @view_context_class = nil super end |
#process ⇒ Object
Overwrite process to setup I18n proxy.
39 40 41 42 43 44 |
# File 'lib/abstract_controller/rendering.rb', line 39 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.
92 93 94 |
# File 'lib/abstract_controller/rendering.rb', line 92 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
107 108 109 110 |
# File 'lib/abstract_controller/rendering.rb', line 107 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
99 100 101 102 103 |
# File 'lib/abstract_controller/rendering.rb', line 99 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.
86 87 88 |
# File 'lib/abstract_controller/rendering.rb', line 86 def view_context view_context_class.new(lookup_context, view_assigns, self) end |