Normalizes arguments, options and then delegates render_to_body and
sticks the result in self.response_body.
def render(*args, &block)
options = _normalize_render(*args, &block)
rendered_body = render_to_body(options)
if options[:html]
_set_html_content_type
else
_set_rendered_content_type rendered_format
end
_set_vary_header
self.response_body = rendered_body
end
Raw rendering of a template to a string.
It is similar to render, except that it does not
set the +response_body+ and it should be guaranteed
to always return a string.
If a component extends the semantics of +response_body+
(as ActionController extends it to be anything that
responds to the method each), this method needs to be
overridden in order to still return a string.
def render_to_string(*args, &block)
options = _normalize_render(*args, &block)
render_to_body(options)
end
renderを呼び出す: 完全なレスポンスを作成してブラウザに送信する
render呼び出しの正確な結果をブラウザを使わずに調べたい場合は、render_to_stringを利用できます。このメソッドの振る舞いは、レンダリング結果をブラウザに返さずに文字列を返す点を除けば、renderと完全に同じです。