Created
September 11, 2013 14:46
-
-
Save jhammann/6524675 to your computer and use it in GitHub Desktop.
A ruby helper that puts the first letter of a string (like a name) in a span to give it a special styling. For example: you want the first letter of a lastname in a special font, this helper creates a span that enables that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def span_capitalize(string) | |
| name = string.match(/(^[a-z])(.*)/i) | |
| first_letter = name[1] | |
| rest = name[2] | |
| content_tag(:span, first_letter) + rest | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment