Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created November 13, 2014 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikecmpbll/72a32f79dc3821e9d2a8 to your computer and use it in GitHub Desktop.
Save mikecmpbll/72a32f79dc3821e9d2a8 to your computer and use it in GitHub Desktop.
Explanation of trim level differences between Erubis and the ERB when Rails used both.
irb(main):045:0> ERB.new("<% if true -%>\nhi\n<% else %>\nbye\n<% end %>", nil, "-").result # old rails with '-'
=> "hi\n"
irb(main):047:0> ERB.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>", nil, "-").result # old rails without '-'
=> "\nhi\n"
irb(main):048:0> Erubis::Eruby.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>").result # new rails with Erubis default trim
=> "hi\n"
irb(main):049:0> Erubis::Eruby.new("<% if true %>\nhi\n<% else %>\nbye\n<% end %>", trim: false).result # Erubis with trimming turned off
=> "\nhi\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment