aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-1317-17/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Fixes grammar in comments on tag_name and tag_idMichael Bock2019-04-251-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.
* Fix unique DOM IDs for collection inputsMark Edmondson2019-01-251-1/+1
|
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-1/+1
| | | | | 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
* Fix leaking special form_with attributes into html attributesYurii Cherniavskyi2018-07-201-1/+1
| | | | | Special form_with attributes `skip_default_ids` and `allow_method_names_outside_object` attributes are leaking into html attributes of option select tag helpers.
* Interpolate '' instead of nil when multiple is false.Dillon Welch2018-03-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "my string #{nil}" results in an additional '' string allocation, I'm guessing because the nil has to be converted to a string. "my string #{'[]' if multiple}" results in "my string #{nil}" if multiple is false. Doing "my string #{''}" does not result in an extra string allocation. I moved the if multiple logic into a method so I only had to make the change once. ```ruby begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" gem "rails" end def allocate_count GC.disable before = ObjectSpace.count_objects yield after = ObjectSpace.count_objects after.each { |k,v| after[k] = v - before[k] } after[:T_HASH] -= 1 # probe effect - we created the before hash. GC.enable result = after.reject { |k,v| v == 0 } GC.start result end @html_options = {} def master_version(multiple=nil) "hi#{"[]" if multiple}" end def fast_version(multiple=nil) str = multiple ? "[]" : '' "hi#{str}" end def test puts "master_version" puts allocate_count { 1000.times { master_version } } puts "master_version with arg" puts allocate_count { 1000.times { master_version(' there') } } puts "fast_version" puts allocate_count { 1000.times { fast_version } } puts "fast_version with arg" puts allocate_count { 1000.times { fast_version(' there') } } Benchmark.ips do |x| x.report("master_version") { master_version } x.report("master_version with arg") { master_version(' there') } x.report("fast_version") { fast_version } x.report("fast_version with arg") { fast_version(' there') } x.compare! end end test ``` results: ```ruby master_version {:FREE=>-1981, :T_STRING=>2052} master_version with arg {:FREE=>-1001, :T_STRING=>1000} fast_version {:FREE=>-1001, :T_STRING=>1000} fast_version with arg {:FREE=>-1001, :T_STRING=>1000} Warming up -------------------------------------- master_version 138.851k i/100ms master_version with arg 164.029k i/100ms fast_version 165.737k i/100ms fast_version with arg 167.016k i/100ms Calculating ------------------------------------- master_version 2.464M (±14.7%) i/s - 11.941M in 5.023307s master_version with arg 3.754M (± 8.5%) i/s - 18.699M in 5.021354s fast_version 3.449M (±11.7%) i/s - 17.071M in 5.033312s fast_version with arg 3.636M (± 6.9%) i/s - 18.205M in 5.034792s Comparison: master_version with arg: 3753896.1 i/s fast_version with arg: 3636094.5 i/s - same-ish: difference falls within error fast_version: 3448766.2 i/s - same-ish: difference falls within error master_version: 2463857.3 i/s - 1.52x slower ```
* Let select render default selected option for required fieldSerj Prikhodko2018-02-271-1/+5
|
* Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-6/+1
|
* Make sure that form_with_generates_ids only affects form_withRafael Mendonça França2017-11-254-2/+5
|
* Change `form_with` to generates ids by defaultnpezza932017-11-255-11/+4
| | | | | | | | | | When `form_with` was introduced we disabled the automatic generation of ids that was enabled in `form_for`. This usually is not an good idea since labels don't work when the input doesn't have an id and it made harder to test with Capybara. You can still disable the automatic generation of ids setting `config.action_view.form_with_generates_ids` to `false.`
* [Action View] require_relative => requireAkira Matsuda2017-10-216-6/+6
| | | | This basically reverts c4d1a4efeec6f0b5b58222993aa0bec85a19b6a8
* Merge pull request #29791 from yui-knk/at_objectRyuta Kamizono2017-09-0513-19/+19
|\ | | | | Do not pass an instance variable to a private method
| * Do not pass an instance variable to a private methodyui-knk2017-09-0513-19/+19
| | | | | | | | | | | | | | | | | | | | | | `ActionView::Helpers::Tags::Base` has `@object` and all passed arguments for * `#value` * `#value_before_type_cast` * `#value_came_from_user?` are `@object`, so we do not need to pass arguments in this case.
* | Allow non-English values for collection_radio_buttons/check_boxescolorfulfool2017-08-021-1/+1
| |
* | Use frozen string literal in actionview/Kir Shatrov2017-07-2435-0/+70
|/
* [Action View] require => require_relativeAkira Matsuda2017-07-016-6/+6
|
* Generate field ids in `collection_check_boxes` and `collection_radio_buttons`yuuji.yaginuma2017-06-112-0/+2
| | | | | This makes sure that the labels are linked up with the fields. Fixes #29014
* Move slicing to initializer.Kasper Timm Hansen2017-06-072-2/+2
| | | | | | Forgot all about https://github.com/rails/rails/pull/28844/files#r113780934 cc @rafaelfranca
* Fix select tag helper used with Enumerable choicesSam Pohlenz2017-05-171-1/+1
| | | | | | Allows a custom object implementing Enumerable to be used as the choices parameter for a select tag, which previously wasn't possible due to the call to `empty?` on the choices (which isn't implemented on Enumerable).
* Remove unnecessary `skip_default_ids` and ↵kyuden2017-04-241-1/+1
| | | | `allow_method_names_outside_object` attributes of select tag in `form_with`
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-052-2/+2
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Generate indexed names in input even when objects are not persistedRafael Mendonça França2017-01-031-2/+13
| | | | | | | | | | | | | | When you ask to generate multiple nested inputs using: field_for('comments[]', Comment.new) do |c| c.text_field :body Rails should generated the names like `post[comments][][body]`. To make sure we don't have regression the fake models now use the same implementation of `#to_param` as `ActiveRecord::Base` Fixes #26942
* No need to nodoc private methodsAkira Matsuda2016-12-242-7/+7
|
* Describe what we are protectingAkira Matsuda2016-12-231-0/+2
|
* form_with: allow methods outside the model.Kasper Timm Hansen2016-12-181-3/+14
| | | | | | | | Has the handy effect of making the initial examples in the form_with docs work too. Had to do some finagling such that form_with's without a scope didn't wrap their names in braces ala `[title]`.
* form_with/fields: Don't output ids by defaultKasper Timm Hansen2016-12-132-3/+15
| | | | | | | | | | | Continuing 67f81cc where we decided not to output ids by default in the new form helpers. Went with @dhh's suggestion of just requiring ids on fields being labelled: https://github.com/rails/rails/issues/25197#issuecomment-231797117 Seems okay enough.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-294-6/+6
|
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-142-6/+6
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Add three new rubocop rulesRafael Mendonça França2016-08-162-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-069-233/+233
|
* modernizes hash syntax in actionviewXavier Noria2016-08-065-10/+10
|
* applies new string literal convention in actionview/libXavier Noria2016-08-069-11/+11
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* New syntax for tag helpers i.e. tag.br instead of tag(br) #25195Marek2016-06-271-2/+2
|
* Fix typo in exception class nameCédric Félizard2016-06-261-1/+1
|
* Change datetime to datetime-local helper tagHerminio Torres2016-06-211-1/+1
| | | | | | | | | | | A change was made in the helper that renders the `datetime`, being now by default `datetime-local` and creating an alias of `datetime-local` for `datetime`, `datetime` tag and it passes to be an abstract class for all other tags that inherit from him. As a new specification of the HTML 5 the text field type `datetime` will no longer exist and will pass a `datetime-local`. Ref: https://html.spec.whatwg.org/multipage/forms.html#local-date-and-time-state-(type=datetime-local)
* Revert "Merge pull request #17973 from maurogeorge/file_field_hidden_field"eileencodes2016-06-211-15/+0
| | | | | | | | | | | | | The reason we are reverting this commit is because it created breaking changes for file upload gems. For more information see discussion here: https://github.com/rails/rails/issues/17947#issuecomment-225154294 This reverts commit c455817804e4df64c46c17a0cdec0e5a1ca5ba2e, reversing changes made to 8b3cd74b8a09ef85a43d7631bb062a9ec7f57227. Conflicts: actionview/CHANGELOG.md actionview/lib/action_view/helpers/form_helper.rb
* Fix doc [ci skip]Daniel Gomez de Souza2016-01-271-1/+1
|
* Fix collection_radio_buttons' hidden_field name and make it appear before ↵Santiago Pastorino2015-12-312-2/+10
| | | | | | the radios Fixes #22773
* Fix week_field returning invalid valueChristoph2015-11-101-1/+1
| | | | | | | According to the W3 spec[1] the value should use a 1-based index and not a 0-based index for the week number. [1]: http://www.w3.org/TR/html-markup/datatypes.html#form.data.week
* Collection check boxes propagates input's id to the label's for attribute.Vasiliy Ermolovich2015-10-201-0/+2
|
* Add a hidden field on the collection_radio_buttonsMauro George2015-09-243-32/+29
| | | | | This will avoid a error be raised when the only input on the form is the `collection_radio_buttons`.
* Raise an ArgumentError when `include_blank` is false for a required field inGrey Baker2015-06-081-3/+9
| | | | | | | | | | `Tags::Base#select_content_tag`. Previously, passing a falsey value to `include_blank` would be ignored if the field was required, and a blank line would still be inserted. The following will now raise instead of quietly failing: `select("post", "category", %w(a required field), { include_blank: false }, required: 'required')`
* Merge pull request #18845 from bogdan/remove-code-dups-in-action-viewRafael Mendonça França2015-02-112-33/+25
|\ | | | | Remove some code duplication in ActionView tags code
| * Remove code duplication in ActionView::Helpers::Tags::BaseBogdan Gusiev2015-02-112-33/+25
| |
* | Remove warning from ActionView::Helpers::Tags::TranslatorYuki Nishijima2015-02-081-1/+3
|/ | | | | | This removes the following warning: /GitHub/rails/actionview/lib/action_view/helpers/tags/translator.rb:19: warning: private attribute?
* Fixed undefined method `i18n_key' for nil:NilClass for labels in non AR form_forMiklos Fazekas2015-02-061-1/+1
| | | | | Refactoring at #18647 broke using non active record objects in form_for. This patch restores the original behaviour where we only compute i18 key when object.respond_to?(:to_model)
* Rename method to make explicit its intentionRafael Mendonça França2015-02-053-3/+3
| | | | call is too generic
* Use kwags to make the argument meaning explicitRafael Mendonça França2015-02-053-6/+6
|
* Use new hash syntaxRafael Mendonça França2015-02-051-1/+1
|