Permalink
Browse files

Merge pull request #31014 from aditya-kapoor/doc-fixes

[ci skip] show the correct example to demonstrate inflections.
  • Loading branch information...
eileencodes committed Nov 4, 2017
2 parents 85cda0f + 23d5d58 commit 300dd48df85d9a65a51dddb692b647fc1d8d1588
Showing with 7 additions and 1 deletion.
  1. +7 −1 activesupport/lib/active_support/inflector/transliterate.rb
@@ -76,13 +76,19 @@ def transliterate(string, replacement = "?".freeze)
# To use a custom separator, override the `separator` argument.
#
# parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
# parameterize("^trés|Jolie-- ", separator: '_') # => "tres_jolie"
# parameterize("^trés|Jolie__ ", separator: '_') # => "tres_jolie"
#
# To preserve the case of the characters in a string, use the `preserve_case` argument.
#
# parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
# parameterize("^trés|Jolie-- ", preserve_case: true) # => "tres-Jolie"
#
# It preserves dashes and underscores unless they are used as separators:
#
# parameterize("^trés|Jolie__ ") # => "tres-jolie__"
# parameterize("^trés|Jolie-- ", separator: "_") # => "tres_jolie--"
# parameterize("^trés_Jolie-- ", separator: ".") # => "tres_jolie--"
#
def parameterize(string, separator: "-", preserve_case: false)
# Replace accented chars with their ASCII equivalents.
parameterized_string = transliterate(string)

0 comments on commit 300dd48

Please sign in to comment.