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 lib/haml/util.rb
This commit is contained in:
commit
8f696076f4
7 changed files with 38 additions and 8 deletions
4
Rakefile
4
Rakefile
|
@ -319,11 +319,11 @@ rescue LoadError; end
|
|||
# ----- Testing Multiple Rails Versions -----
|
||||
|
||||
rails_versions = [
|
||||
"v2.3.0",
|
||||
"v2.3.4",
|
||||
"v2.2.2",
|
||||
"v2.1.2",
|
||||
"v2.0.5"
|
||||
]
|
||||
rails_versions << "v2.0.5" if RUBY_VERSION =~ /^1\.8/
|
||||
|
||||
namespace :test do
|
||||
desc "Test all supported versions of rails. This takes a while."
|
||||
|
|
|
@ -122,6 +122,11 @@ 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.14
|
||||
|
||||
* Don't print warnings when escaping attributes containing non-ASCII characters
|
||||
in Ruby 1.9.
|
||||
|
||||
## [2.2.13](http://github.com/nex3/haml/commit/2.2.13)
|
||||
|
||||
* Allow users to specify {file:HAML_REFERENCE.md#encoding_option `:encoding => "ascii-8bit"`}
|
||||
|
|
|
@ -483,7 +483,9 @@ END
|
|||
# @param text [String] The string to sanitize
|
||||
# @return [String] The sanitized string
|
||||
def escape_once(text)
|
||||
text.to_s.gsub(/[\"><]|&(?!(?:[a-zA-Z]+|(#\d+));)/n) {|s| HTML_ESCAPE[s]}
|
||||
Haml::Util.silence_warnings do
|
||||
text.to_s.gsub(/[\"><]|&(?!(?:[a-zA-Z]+|(#\d+));)/n) {|s| HTML_ESCAPE[s]}
|
||||
end
|
||||
end
|
||||
|
||||
# Returns whether or not the current template is a Haml template.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'erb'
|
||||
require 'set'
|
||||
require 'enumerator'
|
||||
require 'stringio'
|
||||
|
||||
module Haml
|
||||
# A module containing various useful functions.
|
||||
|
@ -133,6 +134,16 @@ module Haml
|
|||
info
|
||||
end
|
||||
|
||||
# Silence all output to STDERR within a block.
|
||||
#
|
||||
# @yield A block in which no output will be printed to STDERR
|
||||
def silence_warnings
|
||||
the_real_stderr, $stderr = $stderr, StringIO.new
|
||||
yield
|
||||
ensure
|
||||
$stderr = the_real_stderr
|
||||
end
|
||||
|
||||
## Cross Rails Version Compatibility
|
||||
|
||||
# Returns the root of the Rails application,
|
||||
|
|
|
@ -1044,6 +1044,11 @@ END
|
|||
assert_equal("<a></a>\n", render('%a{:b => "a #{1 + 1} b", :c => "d"}', :suppress_eval => true))
|
||||
end
|
||||
|
||||
def test_utf8_attrs
|
||||
assert_equal("<a href='héllo'></a>\n", render("%a{:href => 'héllo'}"))
|
||||
assert_equal("<a href='héllo'></a>\n", render("%a(href='héllo')"))
|
||||
end
|
||||
|
||||
# HTML 4.0
|
||||
|
||||
def test_html_has_no_self_closing_tags
|
||||
|
|
|
@ -59,6 +59,16 @@ class UtilTest < Test::Unit::TestCase
|
|||
merge_adjacent_strings(["foo ", "bar ", "baz", :bang, "biz", " bop", 12]))
|
||||
end
|
||||
|
||||
def test_silence_warnings
|
||||
old_stderr, $stderr = $stderr, StringIO.new
|
||||
warn "Out"
|
||||
assert_equal("Out\n", $stderr.string)
|
||||
silence_warnings {warn "In"}
|
||||
assert_equal("Out\n", $stderr.string)
|
||||
ensure
|
||||
$stderr = old_stderr
|
||||
end
|
||||
|
||||
def test_has
|
||||
assert(has?(:instance_method, String, :chomp!))
|
||||
assert(has?(:private_instance_method, Haml::Engine, :set_locals))
|
||||
|
|
|
@ -30,10 +30,7 @@ class Test::Unit::TestCase
|
|||
$stderr = the_real_stderr
|
||||
end
|
||||
|
||||
def silence_warnings
|
||||
the_real_stderr, $stderr = $stderr, StringIO.new
|
||||
yield
|
||||
ensure
|
||||
$stderr = the_real_stderr
|
||||
def silence_warnings(&block)
|
||||
Haml::Util.silence_warnings(&block)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue