aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/text_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
* 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.
* 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 typos. Improve text_helper documentation.James Lovejoy2018-01-191-4/+4
| | | | [ci skip]
* removed unnecessary returnsShuhei Kitagawa2017-10-281-2/+2
|
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Remove unused variable 'regex'kenta-s2017-01-181-1/+1
|
* Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | Mainly around `nil` [ci skip]
* Undeprecate plural positional argumentJeremy Daer2016-09-211-8/+1
| | | | | | | | | | | | | | | | | | ```ruby pluralize people.count, 'person', 'people' ``` reads more naturally than ```ruby pluralize people.count, 'person', plural: 'people' ``` so let's not deprecate it. We could label both, but that's a mouthful: ```ruby pluralize people.count, singular: 'person', plural: 'people' ``` (The `plural:` kwarg shipped in 5.0.0, so we're keeping it.)
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-9/+9
|
* applies new string literal convention in actionview/libXavier Noria2016-08-061-4/+4
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Document `simple_format` handling of `\r`Derek Prior2016-06-271-4/+5
| | | | | | | `simple_format` handles `\r\n` and `\r` but previously did not document this behavior. The handling is done with a `gsub` in `split_paragraphs`. [ci skip]
* Pass the current locale to Inflector from the pluralize text helper.Jaime Iniesta2016-01-101-7/+14
| | | | | | | | | | | The pluralize text helper uses the Inflector to determine the plural form. The inflector accepts an optional parameter for the locale, so we can pass it from the text helper to have locale-aware pluralizations on the text helpers level. The pluralize text helper now only accepts 2 positional arguments: `count` and `singular`. Passing `plural` as a positional argument is now deprecated.
* Sometimes you need a specific break sequence while using word wrap and as ↵Mauricio Gomez Aguinaga2015-08-111-5/+8
| | | | | | | | | | today the only option we have is "\n" and is hardcoded. With this change you will be able to specify any break sequence ("\r\n" for example) as an option. adding proper documentation for break_sequence in ActionView::Helpers::TextHelper.word_wrap adding some more documentation for word_wrap custom break sequence and making sure we use new hash syntax
* Allow `pluralize` helper to take a locale.Stefan Daschek2015-07-091-2/+10
| | | | This is already supported in `ActiveSupport::Inflector#pluralize` and `String#pluralize`, so we just forward the locale.
* [ci skip] Add information about sanitize option in TextHelper#highlightAnton Davydov2015-03-051-1/+6
|
* Fixes simple missprint in docs for #cyle in text_helperBen Woodall2014-12-301-1/+1
|
* Added processing of `nil` to `highlight` helper methodigor042014-09-301-1/+1
|
* Deal with regex match groups in excerptGareth Rees2014-06-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original implementation has bugs if the regex contains a match group. Example: excerpt('This is a beautiful? morning', /\b(beau\w*)\b/i, :radius => 5) Expected: "...is a beautiful? mor..." Actual: "...is a beautifulbeaut..." The original phrase was being converted to a regex and returning the text either side of the phrase as expected: 'This is a beautiful? morning'.split(/beautiful/i, 2) # => ["This is a ", "? morning"] When we have a match with groups the match is returned in the array. Quoting the ruby docs: "If pattern is a Regexp, str is divided where the pattern matches. [...] If pattern contains groups, the respective matches will be returned in the array as well." 'This is a beautiful? morning'.split(/\b(beau\w*)\b/iu, 2) # => ["This is a ", "beautiful", "? morning"] If we assume we want to split on the first match – this fix makes that assumption – we can pass the already assigned `phrase` variable as the place to split (because we already know that a match exists from line 168). Originally spotted by Louise Crow (@crowbot) at https://github.com/mysociety/alaveteli/pull/1557
* 'TextHelper#highlight' now accepts a block to highlight the matched words.Lucas Mazza2014-06-191-3/+14
| | | | | | | | The helper will yield each matched word, and you can use this instead of the ':highlighter' option for more complex replacing logic: highlight('My email is me@work.com', EMAIL_REGEXP) { |m| mail_to(m) } # => 'My email is <a href="mailto:me@work.com">me@work.com</a>'
* highlight() now accepts regular expressions as well.Jan Szumiec2014-06-191-4/+6
|
* excerpt() now accepts regular expression instances as phrases.Jan Szumiec2014-06-191-3/+7
|
* Fixed documentation. [ci skip]Konstantin Wlasow2014-01-041-0/+3
|
* Merge pull request #13059 from imkmf/cycle-accepts-arrayRafael Mendonça França2013-12-061-1/+1
|\ | | | | | | | | | | | | Cycle object should accept an array Conflicts: actionview/CHANGELOG.md
| * A Cycle object should accept an array and cycle through it as it wouldKristian Freeman2013-12-061-1/+1
| | | | | | | | with a set of comma-separated objects.
* | Fix issue where TextHelper#simple_format was calling missing 'raw' methodMario Visic2013-12-051-0/+2
| |
* | Remove the escaping skipRafael Mendonça França2013-12-031-1/+1
| | | | | | | | | | We are generating safe strings in the paragraph, so we can escape the tags
* | Ensure simple_format escapes its html attributesMichael Koziarski2013-12-021-1/+1
|/ | | | | | | | | | The previous behavior equated the sanitize option for simple_format with the escape option of content_tag, however these are two distinct concepts. This fixes CVE-2013-6416 Conflicts: actionview/lib/action_view/helpers/text_helper.rb
* fix simple_format escapes own output when sanitize is set to truepseidemann2013-11-081-1/+1
|
* Cleanup of excerpt helperPaul Nikitochkin2013-09-061-2/+3
| | | | | * replaced String concatenation by joining * separator has default value to '', even it is nil
* Removed an unnecessary loop - it kills performance on large texts.Jan Szumiec2013-08-031-4/+6
|
* Change from `map` => `map!` and `collect!` to save creation of extra array.Vipul A M2013-07-311-2/+2
|
* Fix simple_format output example ending tagMatt Bridges2013-07-091-1/+1
|
* Move actionpack/lib/action_view* into actionview/libPiotr Sarnacki2013-06-201-0/+442