mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'master' of https://github.com/cristianrasch/haml into warnings
This commit is contained in:
commit
521431a2b0
3 changed files with 19 additions and 25 deletions
|
@ -13,7 +13,6 @@ begin
|
||||||
extend Haml::Helpers
|
extend Haml::Helpers
|
||||||
_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
|
_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
|
||||||
_erbout = _hamlout.buffer
|
_erbout = _hamlout.buffer
|
||||||
__in_erb_template = true
|
|
||||||
END
|
END
|
||||||
postamble = <<END.gsub("\n", ";")
|
postamble = <<END.gsub("\n", ";")
|
||||||
#{precompiled_method_return_value}
|
#{precompiled_method_return_value}
|
||||||
|
|
|
@ -73,19 +73,20 @@ module Haml
|
||||||
# @raise [Haml::Error] if there's a Haml syntax error in the template
|
# @raise [Haml::Error] if there's a Haml syntax error in the template
|
||||||
def initialize(template, options = {})
|
def initialize(template, options = {})
|
||||||
@options = {
|
@options = {
|
||||||
:suppress_eval => false,
|
:suppress_eval => false,
|
||||||
:attr_wrapper => "'",
|
:attr_wrapper => "'",
|
||||||
# Don't forget to update the docs in doc-src/REFERENCE.md
|
# Don't forget to update the docs in doc-src/REFERENCE.md
|
||||||
# if you update these
|
# if you update these
|
||||||
:autoclose => %w[meta img link br hr input area param col base],
|
:autoclose => %w[meta img link br hr input area param col base],
|
||||||
:preserve => %w[textarea pre code],
|
:preserve => %w[textarea pre code],
|
||||||
:filename => '(haml)',
|
:filename => '(haml)',
|
||||||
:line => 1,
|
:line => 1,
|
||||||
:ugly => false,
|
:ugly => false,
|
||||||
:format => :xhtml,
|
:format => :xhtml,
|
||||||
:escape_html => false,
|
:escape_html => false,
|
||||||
:escape_attrs => true,
|
:escape_attrs => true,
|
||||||
:hyphenate_data_attrs => true,
|
:hyphenate_data_attrs => true,
|
||||||
|
:ignore_default_internal_encoding => false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +95,10 @@ module Haml
|
||||||
end
|
end
|
||||||
|
|
||||||
unless ruby1_8?
|
unless ruby1_8?
|
||||||
@options[:encoding] = Encoding.default_internal || template.encoding
|
unless options[:ignore_default_internal_encoding]
|
||||||
|
@options[:encoding] = Encoding.default_internal
|
||||||
|
end
|
||||||
|
@options[:encoding] ||= template.encoding
|
||||||
@options[:encoding] = "utf-8" if @options[:encoding].name == "US-ASCII"
|
@options[:encoding] = "utf-8" if @options[:encoding].name == "US-ASCII"
|
||||||
end
|
end
|
||||||
@options.merge! options.reject {|k, v| v.nil?}
|
@options.merge! options.reject {|k, v| v.nil?}
|
||||||
|
@ -126,7 +130,8 @@ module Haml
|
||||||
|
|
||||||
compile(parse)
|
compile(parse)
|
||||||
rescue Haml::Error => e
|
rescue Haml::Error => e
|
||||||
if @index || e.line
|
index = instance_variable_defined?('@index') ? @index : false
|
||||||
|
if index || e.line
|
||||||
e.backtrace.unshift "#{@options[:filename]}:#{(e.line ? e.line + 1 : @index) + @options[:line] - 1}"
|
e.backtrace.unshift "#{@options[:filename]}:#{(e.line ? e.line + 1 : @index) + @options[:line] - 1}"
|
||||||
end
|
end
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -113,20 +113,10 @@ MESSAGE
|
||||||
caller[i+=1] =~ /`(.+?)'/ until $1 and $1.index('test_') == 0
|
caller[i+=1] =~ /`(.+?)'/ until $1 and $1.index('test_') == 0
|
||||||
options[:filename] = "(#{$1})"
|
options[:filename] = "(#{$1})"
|
||||||
end
|
end
|
||||||
|
options[:ignore_default_internal_encoding] = true
|
||||||
Haml::Engine.new(text, options)
|
Haml::Engine.new(text, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
|
||||||
return if Haml::Util.ruby1_8?
|
|
||||||
@old_default_internal = Encoding.default_internal
|
|
||||||
Encoding.default_internal = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
return if Haml::Util.ruby1_8?
|
|
||||||
Encoding.default_internal = @old_default_internal
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_empty_render
|
def test_empty_render
|
||||||
assert_equal "", render("")
|
assert_equal "", render("")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue