aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #36324 from yoones/fix-unexpected-select-tag-delete-behaviorEileen M. Uchitelle2019-05-281-1/+2
|\ | | | | Fix unexpected select_tag delete behavior when include_blank is present
| * Fix select_tag so that is doesn't change options when include_blank is setYounes SERRAJ2019-05-221-1/+2
| |
* | Correct human file size examples [ci skip]Alexander Graul2019-05-201-1/+1
|/ | | | | | | | | | The `number_to_human_size` helpers in Action View and Active Support calculate the "human size" with a base of 1024. The examples should reflect that so they don't confuse the reader. The updated documentations use the values from: helper.number_to_human_size(1500)
* Fixes grammar in comments on tag_name and tag_idMichael Bock2019-04-251-2/+2
|
* url -> URL where apt except inside actionpack/Sharang Dashputre2019-04-012-2/+2
|
* Ruby 2.4 and later support native Unicode case mappingsRyuta Kamizono2019-03-181-1/+1
| | | | Here is only place where we use `mb_chars` internally.
* Merge pull request #35121 from utilum/warning_tried_to_create_proc_without_blockKasper Timm Hansen2019-03-101-2/+2
|\ | | | | Ruby 2.7 warning: creating a Proc without a block
| * Ruby 2.7 warning: creating a Proc without a blockutilum2019-02-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of [Revision 66772]( https://bugs.ruby-lang.org/projects/ruby-trunk/repository/trunk/revisions/66772) `Proc.new` without giving a block emits `warning: tried to create Proc object without a block`. This commit fixes cases where Rails test suit tickles this warning. See CI logs: https://travis-ci.org/rails/rails/jobs/487205819#L1161-L1190 https://travis-ci.org/rails/rails/jobs/487205821#L1154-1159 https://travis-ci.org/rails/rails/jobs/487205821#L1160-L1169 https://travis-ci.org/rails/rails/jobs/487205821#L1189 https://travis-ci.org/rails/rails/jobs/487254404#L1307-L1416 https://travis-ci.org/rails/rails/jobs/487254405#L1174-L1191
* | Updated links from http to https in guides, docs, etcAbhay Nikam2019-03-092-2/+2
| |
* | Removes unnecessary dot in regexpXavier Noria2019-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A string S matches ([.]|\b)html if an only if matches \bhtml: * If S matches [.]html, then it matches \bhtml. * If S matches \bhtml, then it matches \bhtml. Reciprocally: * If S matches \bhtml, then it matches ([.]|\b)html. The character class can be removed, and since we are on it we remove the group too so that it is clear to a reader of the code that there is no grouping going on. References #35166.
* | Templates have one formatAaron Patterson2019-02-251-1/+1
| | | | | | | | | | | | | | Templates only have one format. Before this commit, templates would be constructed with a single element array that contained the format. This commit eliminates the single element array and just implements a `format` method. This saves one array allocation per template.
* | rename push / pop functionAaron Patterson2019-02-191-1/+1
| |
* | Merge pull request #35293 from rails/remove-rendered-format-from-cacheAaron Patterson2019-02-191-5/+5
|\ \ | | | | | | Pass the template format to the digestor
| * | Pass the template format to the digestorAaron Patterson2019-02-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
* | | Allow to pass options to `csp_meta_tag`yuuji.yaginuma2019-02-161-2/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | Currently `csp_meta_tag` generates `name` attribute only. However, in libraries like `Material-UI` and `JSS`, expect that the meta tag that contains the nonce with `property` attribute. https://material-ui.com/css-in-js/advanced/#how-does-one-implement-csp https://github.com/cssinjs/jss/blob/master/docs/csp.md This patch allows `csp_meta_tag` to specify arbitrary options and allows `nonce` to be passed to those libraries.
* / Turn lookup context in to a stack, push and pop if formats changeAaron Patterson2019-02-111-4/+6
|/ | | | | | | | | | | This commit keeps a stack of lookup contexts on the ActionView::Base instance. If a format is passed to render, we instantiate a new lookup context and push it on the stack, that way any child calls to "render" will use the same format information as the parent. This also isolates "sibling" calls to render (multiple calls to render in the same template). Fixes #35222 #34138
* Merge branch 'float_dom_ids'Gannon McGibbon2019-02-051-1/+1
|\ | | | | | | Closes #34975.
| * Fix unique DOM IDs for collection inputsMark Edmondson2019-01-251-1/+1
| |
* | Improve regexp of `html_safe_translation_key?`Kazuhiro NISHIYAMA2019-02-051-1/+1
| | | | | | | | | | | | - Use `\z` instead of `$` - Use character class instead of alternation - Optimize alternation order
* | Prefer ImageProcessing's resize_to_limit macro over resize_to_fitGeorge Claghorn2019-01-241-5/+5
|/ | | | Don't upsize images smaller than the specified dimensions.
* Remove deprecated image_alt helperRafael Mendonça França2019-01-171-23/+0
|
* Fix typo in collection_radio_buttons spec [ci skip]Alberto Almagro2019-01-111-1/+1
|
* Don't expect defined protect_against_forgery? in {token,csrf_meta}_tagGenadi Samokovarov2018-12-272-2/+2
| | | | | | | | | | | | | | | | | | | The `#csrf_meta_tags` and `#token_tag` Action View helper methods are expecting the class in which are included to explicitly define the method `#protect_against_forgery?` or else they will fail with `NoMethodError`. This is a problem if you want to use Action View outside of Rails applications. For example, in #34788 I used the `#button_to` helper inside of the error pages templates that have a custom `ActionView::Base` subclass, which did not defined `#protect_against_forgery?` and trying to call the button failed. I had to dig inside of Action View to find-out what's was going on. I think we should either set a default method implementation in the helpers or check for the method definition, but don't explicitly require the presence of `#protect_against_forgery?` in every `ActionViews::Base` subclass as the errors are hard to figure out.
* Generate doc of methods provided by form builders [ci skip]yuuji.yaginuma2018-12-261-0/+221
| | | | | | | | Because method arguments are different in the methods provided by form helpers and form builders, I think these are necessary to prevent confusion. Fixes #34787
* Fix integer regex deprecation warnings for Ruby 2.6.0 (#34728)Vinicius Stock2018-12-211-1/+1
| | | | | * Fix integer regex deprecation warnings for Ruby 2.6.0 * Define =~ in FakeZone to avoid warnings from Ruby 2.6.0
* Prevent TextHelper#word_wrap from stripping white space on the leftLyle Mullican2018-11-191-1/+1
| | | | side of long lines; Fixes #34487
* Added maxlength example to text_field documentationRaghu Kamat2018-10-251-0/+3
| | | | | | | | | | | The usage of maxlength in the text_field helper adds a size attribute to the generated text_field input with the same value as the maxlength. This implicit addition of size attribute by the method gives a false impression that it may be bug. By adding the implementation of the maxlength to the api docs, we explicitly tell the reader referring the api doc that addition of size along with maxlength is the expected behaviour. [ci skip]
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-298-33/+33
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-234-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Merge pull request #33564 from avit/escape_javascript_castingRafael França2018-09-211-4/+5
|\ | | | | Let escape_javascript handle conversion to string
| * Let escape_javascript handle conversion to stringAndrew Vit2018-09-211-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | This brings `escape_javascript` in line with the behavior of `json_escape` and allows other value types to be output without needing explicit casting in the view template. Example: <%= javascript_tag do %> var locale = '<%== j I18n.locale %>'; // locale is a symbol <% end %>
* | Move digest path calculation out of loopschneems2018-09-111-9/+17
| | | | | | | | | | | | | | | | | | | | | | On every iteration of generating a cache for a collection a “digest path” is calculated even though it’s exactly the same for every element. This PR exposes a method `digest_path_from_virtual` that returns back a “digest_path”. This can in turn be passed back into `cache_fragment_name`. This not only does less work, but it also (you guessed it) uses less memory. before: Total allocated: 762539 bytes (7035 objects) after: Total allocated: 743590 bytes (6621 objects) (762539 - 743590)/ 762539.0 # => 2.4% faster ⚡️⚡️
* | [ci skip] Doc ActionView::OutputBufferschneems2018-09-061-3/+2
| |
* | [ci skip] Clarify CaptureHelper#capture functionschneems2018-09-061-0/+5
| |
* | Merge pull request #33718 from kddeisz/permit-listMatthew Draper2018-08-291-2/+2
|\ \ | | | | | | Finish converting whitelist and blacklist references
| * | Permit list usage cleanup and clearer documentationKevin Deisz2018-08-271-1/+1
| | |
| * | Convert over the rest of the whitelist referencesKevin Deisz2018-08-241-2/+2
| | |
* | | Add `:namespace` option to the api docs of `form_with` [ci skip]bogdanvlviv2018-08-271-0/+3
|/ /
* | Merge pull request #33547 from Ana06/patch-1Matthew Draper2018-08-231-2/+10
|\ \ | | | | | | | | | Use public_send in value_for_collection
| * | Deprecate use of private methods in view's helpersAna María Martínez Gómez2018-08-081-2/+12
| | | | | | | | | | | | | | | Instead of dropping it completely in case someone is relying (probably inadvertenly) on it.
| * | Use public_send in extract_values_from_collectionAna María Martínez Gómez2018-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid exposing private methods in view's helpers. However, as `extract_values_from_collection` is only called from `options_from_collection_for_select` where `value_for_collection` is previously called, this case was already covered. The change makes anyway sense for consistency and in case the code changes in the future.
| * | Use public_send in value_for_collectionAna María Martínez Gómez2018-08-071-1/+1
| |/ | | | | | | | | | | Avoid exposing private methods in view's helpers. Fixes https://github.com/rails/rails/issues/33546
* | Merge pull request #31132 from ↵Ryuta Kamizono2018-08-201-0/+5
|\ \ | | | | | | | | | | | | | | | | | | emaxi/feature/add-missing-documentation-option-to-number-to-currency Add missing documentation option to number_to_currency [ci skip]
| * | Add missing documentation options to number_to_currency [ci skip]emaxi2018-07-111-0/+5
| | |
* | | Enable Style/ParenthesesAroundCondition copRyuta Kamizono2018-08-191-1/+1
| | | | | | | | | | | | To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
* | | Fix unclosed tags [ci skip]yuuji.yaginuma2018-08-181-1/+1
| |/ |/|
* | [ci skip] Change references from Rake task to Rails commandAlberto Almagro2018-08-011-2/+3
| | | | | | | | | | This commit follows the path we started at commit #ea4f0e2 and continued at PR #33229.
* | Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-282-2/+2
| | | | | | | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* | Merge pull request #33268 from benpickles/remove-pubdate-from-docsRichard Schneeman2018-07-211-2/+0
|\ \ | | | | | | Keep time_tag docs up-to-date.
| * | Keep time_tag docs up-to-date.Ben Pickles2018-07-011-2/+0
| | | | | | | | | | | | | | | The pubdate attribute was removed from the spec, see 940eec417f20e53abd3e3114c7fa845dac0d3a62 for context.