mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Drop support for Rails 3.
This commit is contained in:
parent
ad2503cf9b
commit
1f8821ce8b
8 changed files with 26 additions and 55 deletions
|
@ -8,17 +8,10 @@ rvm:
|
|||
- jruby
|
||||
- rbx-2
|
||||
gemfile:
|
||||
- test/gemfiles/Gemfile.rails-3.2.x
|
||||
- test/gemfiles/Gemfile.rails-4.0.x
|
||||
- test/gemfiles/Gemfile.rails-4.1.x
|
||||
- test/gemfiles/Gemfile.rails-4.2.x
|
||||
matrix:
|
||||
exclude:
|
||||
- { rvm: jruby, gemfile: test/gemfiles/Gemfile.rails-3.2.x }
|
||||
- { rvm: rbx-2, gemfile: test/gemfiles/Gemfile.rails-3.2.x }
|
||||
- { rvm: 2.0.0, gemfile: test/gemfiles/Gemfile.rails-3.2.x }
|
||||
- { rvm: 2.1, gemfile: test/gemfiles/Gemfile.rails-3.2.x }
|
||||
- { rvm: 2.2, gemfile: test/gemfiles/Gemfile.rails-3.2.x }
|
||||
allow_failures:
|
||||
- rvm: jruby
|
||||
- rvm: rbx-2
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
## 5.0.0 (Unreleased)
|
||||
|
||||
* Haml now requires Ruby 1.9.2 or above.
|
||||
* Rails 3.0 and 3.1 are no longer supported, matching the official
|
||||
* Haml now requires Ruby 2.0.0 or above.
|
||||
* Rails 3 is no longer supported, matching the official
|
||||
[Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
|
||||
(Tee Parham)
|
||||
* Fix for attribute merging. When an attribute method (or literal nested hash)
|
||||
|
|
|
@ -42,8 +42,7 @@ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
|
|||
gem 'haml'
|
||||
~~~
|
||||
|
||||
Haml 5 requires Rails version 3.2 or later. If you are using Rails 3.0 or 3.1,
|
||||
you should use Haml version 4.0.x:
|
||||
Haml 5 will require Rails version 4.0 or later. If you are using Rails 3.x, you should use Haml version 4.0.x:
|
||||
|
||||
~~~ruby
|
||||
gem 'haml', '~> 4.0.5'
|
||||
|
|
|
@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|||
|
||||
spec.add_dependency 'tilt'
|
||||
|
||||
spec.add_development_dependency 'rails', '>= 3.2.0'
|
||||
spec.add_development_dependency 'rails', '>= 4.0.0'
|
||||
spec.add_development_dependency 'rbench'
|
||||
spec.add_development_dependency 'minitest', '>= 4.0'
|
||||
spec.add_development_dependency 'nokogiri', '~> 1.6.0'
|
||||
|
|
|
@ -82,11 +82,9 @@ module ActionView
|
|||
end
|
||||
end
|
||||
|
||||
if ActionPack::VERSION::MAJOR == 4
|
||||
module Tags
|
||||
class TextArea
|
||||
include HamlSupport
|
||||
end
|
||||
module Tags
|
||||
class TextArea
|
||||
include HamlSupport
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Haml
|
|||
|
||||
def compile(template)
|
||||
options = Haml::Template.options.dup
|
||||
if (ActionPack::VERSION::MAJOR >= 4) && template.respond_to?(:type)
|
||||
if template.respond_to?(:type)
|
||||
options[:mime_type] = template.type
|
||||
elsif template.respond_to? :mime_type
|
||||
options[:mime_type] = template.mime_type
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem 'rails', '~> 3.2.0'
|
||||
gemspec :path => "../.."
|
|
@ -5,8 +5,9 @@ class FormModel
|
|||
extend ActiveModel::Naming
|
||||
end
|
||||
|
||||
|
||||
class HelperTest < Haml::TestCase
|
||||
TEXT_AREA_CONTENT_REGEX = /<(textarea)[^>]*>\n(.*?)<\/\1>/im
|
||||
|
||||
Post = Struct.new('Post', :body, :error_field, :errors)
|
||||
class PostErrors
|
||||
def on(name)
|
||||
|
@ -164,29 +165,15 @@ HAML
|
|||
render('= content_tag "pre", "Foo bar\n baz"', :action_view))
|
||||
end
|
||||
|
||||
# Rails >= 3.2.3 adds a newline after opening textarea tags.
|
||||
def self.rails_text_area_helpers_emit_a_newline?
|
||||
major, minor, tiny = ActionPack::VERSION::MAJOR, ActionPack::VERSION::MINOR, ActionPack::VERSION::TINY
|
||||
major == 4 || ((major == 3) && (minor >= 2) && (tiny >= 3))
|
||||
end
|
||||
|
||||
def text_area_content_regex
|
||||
@text_area_content_regex ||= if self.class.rails_text_area_helpers_emit_a_newline?
|
||||
/<(textarea)[^>]*>\n(.*?)<\/\1>/im
|
||||
else
|
||||
/<(textarea)[^>]*>(.*?)<\/\1>/im
|
||||
end
|
||||
end
|
||||
|
||||
def test_text_area_tag
|
||||
output = render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view)
|
||||
match_data = output.match(text_area_content_regex)
|
||||
match_data = output.match(TEXT_AREA_CONTENT_REGEX)
|
||||
assert_equal "Foo
Bar
 Baz
 Boom", match_data[2]
|
||||
end
|
||||
|
||||
def test_text_area
|
||||
output = render('= text_area :post, :body', :action_view)
|
||||
match_data = output.match(text_area_content_regex)
|
||||
match_data = output.match(TEXT_AREA_CONTENT_REGEX)
|
||||
assert_equal "Foo bar
baz", match_data[2]
|
||||
end
|
||||
|
||||
|
@ -194,26 +181,24 @@ HAML
|
|||
# non-indentation of textareas rendered inside partials
|
||||
@base.instance_variable_set(:@post, Post.new("Foo", nil, PostErrors.new))
|
||||
output = render(".foo\n .bar\n = render '/text_area_helper'", :action_view)
|
||||
match_data = output.match(text_area_content_regex)
|
||||
match_data = output.match(TEXT_AREA_CONTENT_REGEX)
|
||||
assert_equal 'Foo', match_data[2]
|
||||
end
|
||||
|
||||
if rails_text_area_helpers_emit_a_newline?
|
||||
def test_textareas_should_preserve_leading_whitespace
|
||||
# leading whitespace preservation
|
||||
@base.instance_variable_set(:@post, Post.new(" Foo", nil, PostErrors.new))
|
||||
output = render(".foo\n = text_area :post, :body", :action_view)
|
||||
match_data = output.match(text_area_content_regex)
|
||||
assert_equal '  Foo', match_data[2]
|
||||
end
|
||||
def test_textareas_should_preserve_leading_whitespace
|
||||
# leading whitespace preservation
|
||||
@base.instance_variable_set(:@post, Post.new(" Foo", nil, PostErrors.new))
|
||||
output = render(".foo\n = text_area :post, :body", :action_view)
|
||||
match_data = output.match(TEXT_AREA_CONTENT_REGEX)
|
||||
assert_equal '  Foo', match_data[2]
|
||||
end
|
||||
|
||||
def test_textareas_should_preserve_leading_whitespace_in_partials
|
||||
# leading whitespace in textareas rendered inside partials
|
||||
@base.instance_variable_set(:@post, Post.new(" Foo", nil, PostErrors.new))
|
||||
output = render(".foo\n .bar\n = render '/text_area_helper'", :action_view)
|
||||
match_data = output.match(text_area_content_regex)
|
||||
assert_equal '  Foo', match_data[2]
|
||||
end
|
||||
def test_textareas_should_preserve_leading_whitespace_in_partials
|
||||
# leading whitespace in textareas rendered inside partials
|
||||
@base.instance_variable_set(:@post, Post.new(" Foo", nil, PostErrors.new))
|
||||
output = render(".foo\n .bar\n = render '/text_area_helper'", :action_view)
|
||||
match_data = output.match(TEXT_AREA_CONTENT_REGEX)
|
||||
assert_equal '  Foo', match_data[2]
|
||||
end
|
||||
|
||||
def test_capture_haml
|
||||
|
|
Loading…
Reference in a new issue