1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Merge branch 'stable'

Conflicts:
	doc-src/HAML_CHANGELOG.md
This commit is contained in:
Nathan Weizenbaum 2009-11-08 16:17:38 -08:00
commit 2ce9601720
4 changed files with 36 additions and 3 deletions

View file

@ -122,6 +122,13 @@ including the line number and the offending character.
* Multi-line ERB statements are now properly indented,
and those without any content are removed.
## 2.2.13 (Unreleased)
* Allow users to specify {file:HAML_REFERENCE.md#encoding_option `:encoding => "ascii-8bit"`}
even for templates that include non-ASCII byte sequences.
This makes Haml templates not crash when given non-ASCII input
that's marked as having an ASCII encoding.
## [2.2.12](http://github.com/nex3/haml/commit/2.2.12)
There were no changes made to Sass between versions 2.2.11 and 2.2.12.

View file

@ -192,6 +192,14 @@ Available options are:
before being passed into the Haml template.
Defaults to `Encoding.default_internal` or, if that's not set, `"utf-8"`.
Many Ruby database drivers are not yet Ruby 1.9 compatible;
in particular, they return strings marked as ASCII-encoded
even when those strings contain non-ASCII characters (such as UTF-8).
**This will cause encoding errors** if the Haml encoding isn't set to `"ascii-8bit"`.
To solve this, either call `#force_encoding` on all the strings returned from the database,
set `:encoding` to `"ascii-8bit"`, or try to get the authors of the database drivers
to make them Ruby 1.9 compatible.
## Plain Text
A substantial portion of any HTML document is its content,

View file

@ -58,7 +58,9 @@ module Haml
# @return [String]
def precompiled
return @precompiled if ruby1_8?
return @precompiled.encode(Encoding.find(@options[:encoding]))
encoding = Encoding.find(@options[:encoding])
return @precompiled.force_encoding(encoding) if encoding == Encoding::BINARY
return @precompiled.encode(encoding)
end
# Precompiles the Haml template.

View file

@ -837,12 +837,18 @@ HAML
line_no ||= key.split("\n").length
if expected_message == :compile
assert_match(/^compile error\n/, err.message, "Line: #{key}")
if Haml::Util.ruby1_8?
assert_match(/^compile error\n/, err.message, "Line: #{key}")
else
assert_match(/^#{Regexp.quote __FILE__}:#{line_no}: syntax error,/, err.message, "Line: #{key}")
end
else
assert_equal(expected_message, err.message, "Line: #{key}")
end
assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, err.backtrace[0], "Line: #{key}")
if Haml::Util.ruby1_8?
assert_match(/^#{Regexp.escape(__FILE__)}:#{line_no}/, err.backtrace[0], "Line: #{key}")
end
else
assert(false, "Exception not raised for\n#{key}")
end
@ -1194,6 +1200,16 @@ HTML
HAML
end
def test_fake_ascii_encoding
assert_equal(<<HTML.force_encoding("ascii-8bit"), render(<<HAML, :encoding => "ascii-8bit"))
<p>bâr</p>
<p>föö</p>
HTML
%p bâr
%p föö
HAML
end
def test_convert_template_render_proc
assert_converts_template_properly {|e| e.render_proc.call}
end