Introduce :plain, :html, and :body render options.#14062
Introduce :plain, :html, and :body render options.#14062rafaelfranca merged 10 commits intorails:masterfrom
:plain, :html, and :body render options.#14062Conversation
There was a problem hiding this comment.
We don't need to freeze this
There was a problem hiding this comment.
Could you wrap new additions in the guides around 80 chars please ?
Awesome work so far! ❤️
|
@sikachu, do you expect to be able to wrap this up today or should we delay it to 4.2.0? |
|
I can respond to reviews this morning! Sorry for the delay. On Tue, Feb 18, 2014 at 5:10 AM, David Heinemeier Hansson
|
|
I've addressed all of the comments so far. This should be ready to go. |
There was a problem hiding this comment.
this "ruby" is not in the wrong line?
There was a problem hiding this comment.
It is. Fixing ...
On Tue, Feb 18, 2014 at 12:02 PM, Rafael Mendonça França
notifications@github.com wrote:
@@ -276,6 +298,19 @@ render js: "alert('Hello Rails');"
This will send the supplied string to the browser with a MIME type of
text/javascript.+#### Rendering raw body
+
+You can send a raw content back to the browser, without setting any content
+type, by using the:bodyoption torender:
+
+```
+ruby render body: "raw"this "ruby" is not in the wrong line?
Reply to this email directly or view it on GitHub:
https://github.com/rails/rails/pull/14062/files#r9831304
This is an option for sending a raw content back to browser. Note that this rendering option will unset the default content type and does not include "Content-Type" header back in the response. You should only use this option if you are expecting the "Content-Type" header to not be set. More information on "Content-Type" header can be found on RFC 2616, section 7.2.1. Please see rails#12374 for more detail.
This is as an option to render content with a content type of `text/plain`. This is the preferred option if you are planning to render a plain text content. Please see rails#12374 for more detail.
This is an option for to HTML content with a content type of `text/html`. This rendering option calls `ERB::Util.html_escape` internally to escape unsafe HTML string, so you will have to mark your string as html safe if you have any HTML tag in it. Please see rails#12374 for more detail.
This test were assuming that the list of render options will always be the same. Fixing that so this doesn't break when we add/remove render option in the future.
* Introduces `:plain`, `:html`, `:body` render option. * Update guide to use `render :plain` instead of `render :text`.
Setting this attribute to `true` will remove the content type header from the request. This is use in `render :body` feature.
Introduce `:plain`, `:html`, and `:body` render options.
* master: (1455 commits) change 'assert !' to 'assert_not' in guides [ci skip] Pointing to latest guides [ci skip] Methods silence_stream/quietly are not thread-safe [skip ci] [ci skip] Close the meta tag with '/>' instead of '>' Fix render plain docs example in AM::Base Update Docs in favor to use render plain instead of text option ref #14062 Typo fix for unscope Use the reference for the mime type to get the format Preparing for 4.1.0.beta2 release Correctly escape PostgreSQL arrays. Escape format, negative_format and units options of number helpers Sync 4.1 release notes with changes since 7f648bc [ci skip] Update upgrading guide regarding `render :text` Add `#no_content_type` attribute to `AD::Response` Add missing CHANGELOG entry to Action View Update guides for new rendering options Cleanup `ActionController::Rendering` Fix a fragile test on `action_view/render` Introduce `render :html` for render HTML string Introduce `render :plain` for render plain text ... Conflicts: actionmailer/lib/action_mailer/railtie.rb railties/lib/rails/application.rb railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
Use render plain: instead of text: This is in preparation of rails 5 update. Chips away: e0a5d2e ( minus env deprecation). `render plain: ` was introduced in rails 4.1. rails/rails#14062
- `render plain:` was introduced in Rails 4.1 rails/rails#14062
This is a continuation from #12374, with slight modification since the discussion went a bit off-topic.
Per discussion,
render :textmisdirect people to think that it would render content withtext/plainMIME type. However,render :textactually sets the response body directly, and inherits the default response MIME type, which istext/html.In order to reduce confusion, we're introducing 3 more render format to
render:We want to phrase out the usage of
render :text, to reduce the confusion in the future. There were some discussion about deprecaterender :text, but we haven't come into a conclusion yet. So, we'll consider doing that before the next major release.Fixes #12374