diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2012-08-07 11:44:24 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2012-08-07 11:44:24 -0500 |
commit | 666d3fd0c156a5c47eeddfe87dc466863890ba70 (patch) | |
tree | 48efad07255a30ea809921b1983899e21d409523 | |
parent | fb883318c8b82b3570cee022ddf6886f9052245d (diff) | |
download | rails-666d3fd0c156a5c47eeddfe87dc466863890ba70.tar.gz rails-666d3fd0c156a5c47eeddfe87dc466863890ba70.tar.bz2 rails-666d3fd0c156a5c47eeddfe87dc466863890ba70.zip |
Revert "Merge pull request #7033 from kron4eg/master". Not a a fan at all of what this makes ERB files look like.
This reverts commit 46b8bceedd3e47169c50a04c93161424909c75fb, reversing
changes made to 2f58795e783150f2e1b1f6c64e305703f0061129.
-rw-r--r-- | actionpack/CHANGELOG.md | 12 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 14 | ||||
-rw-r--r-- | actionpack/test/template/erb/handlers_test.rb | 54 |
3 files changed, 4 insertions, 76 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 45940e722f..236768227c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,17 +1,5 @@ ## Rails 4.0.0 (unreleased) ## -* Restored support for the "%" ERb/Erubis _trim mode_. This can be activated with: - - config.action_view.erb_trim_mode = "%" # or "%-" whitespace trim - - With that mode active, you can use a single percent sign at the beginning of a line to engage Ruby mode (without inserting results). It allows for template code like this: - - % if current_user.try(:admin?) - <%= render "edit_links" %> - % end - - *James Edward Gray II* - * `javascript_include_tag :all` will now not include `application.js` if the file does not exists. *Prem Sichanugrist* * Send an empty response body when call `head` with status between 100 and 199, 204, 205 or 304. diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index 4e80c4f456..aa8eac7846 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -37,10 +37,6 @@ module ActionView end end - class ErubisWithPercentLine < Erubis - include ::Erubis::PercentLineEnhancer - end - class ERB # Specify trim mode for the ERB compiler. Defaults to '-'. # See ERB documentation for suitable values. @@ -80,12 +76,10 @@ module ActionView # Always make sure we return a String in the default_internal erb.encode! - mode = self.class.erb_trim_mode.to_s - implementation = self.class.erb_implementation - if mode.include? "%" and implementation == Erubis - implementation = ErubisWithPercentLine - end - implementation.new(erb, :trim => mode.include?("-")).src + self.class.erb_implementation.new( + erb, + :trim => (self.class.erb_trim_mode == "-") + ).src end private diff --git a/actionpack/test/template/erb/handlers_test.rb b/actionpack/test/template/erb/handlers_test.rb deleted file mode 100644 index 7cd9c7fbcb..0000000000 --- a/actionpack/test/template/erb/handlers_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require "abstract_unit" - -class HandlersTest < ActiveSupport::TestCase - HANDLER = ActionView::Template::Handlers::ERB - Template = Struct.new(:source) - - extend ActiveSupport::Testing::Declarative - - test "content is not trimmed without a trim mode" do - with_erb_trim_mode nil do - assert_equal(" \ntest", render(" <% 'IGNORED' %> \ntest")) - end - end - - test "content around tags is trimmed if the trim mode includes a dash" do - with_erb_trim_mode '-' do - assert_equal("test", render(" <% 'IGNORED' %> \ntest")) - end - end - - test "percent lines are normal content without a trim mode" do - with_erb_trim_mode nil do - assert_equal( "% if false\noops\n% end\n", - render("% if false\noops\n% end\n") ) - end - end - - test "percent lines count as ruby if trim mode includes a percent" do - with_erb_trim_mode "%" do - assert_equal("", render("% if false\noops\n% end\n")) - end - end - - test "both trim modes can be used at the same time" do - with_erb_trim_mode "%-" do - assert_equal( "test", render( "% if false\noops\n% end\n" + - " <% 'IGNORED' %> \ntest" ) ) - end - end - - private - - def with_erb_trim_mode(mode) - @old_erb_trim_mode = HANDLER.erb_trim_mode - HANDLER.erb_trim_mode = mode - yield - ensure - HANDLER.erb_trim_mode = @old_erb_trim_mode - end - - def render(template) - eval("output_buffer = nil; " + HANDLER.call(Template.new(template))) - end -end |