Bug #7608

Document ERB::new trim_mode parameter

Added by Tom Pave over 1 year ago. Updated over 1 year ago.

[ruby-core:51084]
Status:Closed
Priority:Low
Assignee:Zachary Scott
Category:doc
Target version:2.0.0
ruby -v:MRI 1.9.3-p327 Backport:

Description

=begin
I believe the documentation for the ((ERB::new|URL:http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/ERB.html#method-c-new)) method could be improved. Specifically, the list of available arguments for the (({trim_mode})) paramenter doesn't seem complete. I found you can use the option (({"-"})) to make the tags (({<% -%>})) work. (by the way... It looks like those tags aren't documented either).

Without that option the (({<% -%>})) tags don't work properly. I made several tests and can confirm the issue affects both Ruby 1.8.7 and 1.9.3.
I've attached a short file (70 lines including whitespace) to reproduce the problem. Comments indicate what goes wrong, and I have provided a commented out line that works instead (as it uses the undocumented (({trim_mode="-"})) option).

I came across the issue while working on a plain ruby script, but I used the same code in a Rails app with no problems at all, so I guess that ERB text is parsed in Rails with (({trim_mode="-"})) by default.
=end

QRCoder.rb Magnifier (1.33 KB) Tom Pave, 12/23/2012 01:40 PM

Associated revisions

Revision 38572
Added by Zachary Scott over 1 year ago

  • lib/erb.rb: Document ERB::new trim_mode '-' for lines ending in -%> [Bug #7608]

History

#1 Updated by Zachary Scott over 1 year ago

  • Subject changed from Documentation, Std-lib, ERB to Document ERB::new trim_mode parameter
  • Assignee set to Zachary Scott
  • Target version changed from Next Major to 2.0.0

#2 Updated by Zachary Scott over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38572.
Tom, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/erb.rb: Document ERB::new trim_mode '-' for lines ending in -%> [Bug #7608]

Also available in: Atom PDF