mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Revert "[Haml] Fix :encoding under 1.9.2."
This reverts commit 1f320ab147
.
Conflicts:
doc-src/HAML_CHANGELOG.md
This commit is contained in:
parent
50d89b574f
commit
b43ff69bb8
4 changed files with 20 additions and 18 deletions
|
@ -5,8 +5,6 @@
|
|||
|
||||
## 3.0.19 (Unreleased)
|
||||
|
||||
* Properly respect the `:encoding` option under Ruby 1.9.2.
|
||||
|
||||
* Allow the `--unix-newlines` flag to work on Unix, where it's a no-op.
|
||||
|
||||
## 3.0.18
|
||||
|
|
|
@ -91,7 +91,7 @@ module Haml
|
|||
@active = true
|
||||
@upper = upper
|
||||
@options = options
|
||||
@buffer = ""
|
||||
@buffer = ruby1_8? ? "" : "".encode(Encoding.find(options[:encoding]))
|
||||
@tabulation = 0
|
||||
|
||||
# The number of tabs that Engine thinks we should have
|
||||
|
|
|
@ -56,7 +56,12 @@ module Haml
|
|||
# (see {file:HAML_REFERENCE.md#encoding-option the `:encoding` option}).
|
||||
#
|
||||
# @return [String]
|
||||
attr_reader :precompiled
|
||||
def precompiled
|
||||
return @precompiled if ruby1_8?
|
||||
encoding = Encoding.find(@options[:encoding])
|
||||
return @precompiled.force_encoding(encoding) if encoding == Encoding::BINARY
|
||||
return @precompiled.encode(encoding)
|
||||
end
|
||||
|
||||
# Precompiles the Haml template.
|
||||
#
|
||||
|
@ -88,6 +93,7 @@ module Haml
|
|||
|
||||
unless ruby1_8?
|
||||
@options[:encoding] = Encoding.default_internal || template.encoding
|
||||
@options[:encoding] = "utf-8" if @options[:encoding].name == "US-ASCII"
|
||||
end
|
||||
@options.merge! options.reject {|k, v| v.nil?}
|
||||
@index = 0
|
||||
|
@ -96,29 +102,19 @@ module Haml
|
|||
raise Haml::Error, "Invalid output format #{@options[:format].inspect}"
|
||||
end
|
||||
|
||||
unless ruby1_8?
|
||||
unless @options[:encoding].is_a?(Encoding)
|
||||
@options[:encoding] = Encoding.find(@options[:encoding])
|
||||
end
|
||||
|
||||
template =
|
||||
if @options[:encoding] == Encoding::BINARY
|
||||
template.force_encoding(@options[:encoding])
|
||||
else
|
||||
template.encode(@options[:encoding])
|
||||
end
|
||||
if @options[:encoding] && @options[:encoding].is_a?(Encoding)
|
||||
@options[:encoding] = @options[:encoding].name
|
||||
end
|
||||
|
||||
# :eod is a special end-of-document marker
|
||||
@template = (template.rstrip).split(/\r\n|\r|\n/) + [:eod, :eod]
|
||||
@template_encoding = template.encoding
|
||||
@template_index = 0
|
||||
@to_close_stack = []
|
||||
@output_tabs = 0
|
||||
@template_tabs = 0
|
||||
@flat = false
|
||||
@newlines = 0
|
||||
@precompiled = ''.encode(template.encoding)
|
||||
@precompiled = ''
|
||||
@to_merge = []
|
||||
@tab_change = 0
|
||||
|
||||
|
@ -296,6 +292,7 @@ module Haml
|
|||
:attr_wrapper => @options[:attr_wrapper],
|
||||
:ugly => @options[:ugly],
|
||||
:format => @options[:format],
|
||||
:encoding => @options[:encoding],
|
||||
:escape_html => @options[:escape_html],
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1506,7 +1506,7 @@ HAML
|
|||
|
||||
def test_loud_ruby_multiline_with_block
|
||||
assert_equal(<<HTML, render(<<HAML))
|
||||
#{%w[far faz fang]}
|
||||
farfazfang
|
||||
<p>foo</p>
|
||||
<p>bar</p>
|
||||
HTML
|
||||
|
@ -1629,6 +1629,13 @@ HAML
|
|||
end
|
||||
|
||||
unless Haml::Util.ruby1_8?
|
||||
def test_default_encoding
|
||||
assert_equal(Encoding.find("utf-8"), render(<<HAML.encode("us-ascii")).encoding)
|
||||
%p bar
|
||||
%p foo
|
||||
HAML
|
||||
end
|
||||
|
||||
def test_convert_template_render
|
||||
assert_equal(<<HTML, render(<<HAML.encode("iso-8859-1"), :encoding => "utf-8"))
|
||||
<p>bâr</p>
|
||||
|
|
Loading…
Reference in a new issue