Method: String#textarea_ize
- Defined in:
- lib/el4r/el4r-sub.rb
#textarea_ize(cols = nil, rows = nil, escape = true) ⇒ Object
Makes a string textarea-ize. COLS is adjusted to terminal by default. String is HTML escaped when ESCAPE is true.
496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/el4r/el4r-sub.rb', line 496 def textarea_ize(cols=nil, rows=nil, escape=true) cols ||= textarea_default_cols rows = self.split(/\r?\n/).inject(0){|result, item| result + (item.length/cols+1)}+1 unless rows content = if escape require 'fastesc' self.html_escape else self end "<textarea rows=#{rows} cols=#{cols}>#{content}</textarea>" end |