Skip to content

Commit

Permalink
Merge remote branch 'refs/remotes/origin/stable' into stable
Browse files Browse the repository at this point in the history
Conflicts:
	doc-src/SASS_CHANGELOG.md
  • Loading branch information
nex3 committed Dec 8, 2010
2 parents 2627ecf + 67a662e commit 5f06cdd
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 19 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.23
3.0.24
10 changes: 10 additions & 0 deletions doc-src/HAML_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
* Table of contents
{:toc}

## 3.0.24

[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.24).

* `html2haml` now properly generates Haml for silent script expressions
nested within blocks.

* IronRuby compatibility. This is sort of a hack: IronRuby reports its version as 1.9,
but it doesn't support the encoding APIs, so we treat it as 1.8 instead.

## 3.0.23

[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.23).
Expand Down
20 changes: 16 additions & 4 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@
* Table of contents
{:toc}

## 3.0.24 (Unreleased)
## 3.0.25 (Unreleased)

* Raise an error when `@else` appears without an `@if` in SCSS.
* When displaying a Sass error in an imported stylesheet,
use the imported stylesheet's contents rather than the top-level stylesheet.

* Fix some cases where `@if` rules were causing the line numbers in error reports
to become incorrect.
* Fix a bug that caused some lines with non-ASCII characters to be ignored in Ruby 1.8.

* Fix a bug where boolean operators (`and`, `or`, and `not`) wouldn't work at the end of a line
in a multiline SassScript expression.

* Fix a performance bug in large SCSS stylesheets with many nested selectors.
This should dramatically decrease compilation time of such stylesheets.

## 3.0.24

[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.24).

* Raise an error when `@else` appears without an `@if` in SCSS.

* Fix some cases where `@if` rules were causing the line numbers in error reports
to become incorrect.

## 3.0.23

[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.23).
Expand Down
11 changes: 10 additions & 1 deletion lib/haml/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,18 @@ def process_result
# @param color [Symbol] The name of the color to use for this action.
# Can be `:red`, `:green`, or `:yellow`.
def puts_action(name, color, arg)
return if @options[:for_engine][:quiet]
printf color(color, "%11s %s\n"), name, arg
end

# Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
#
# @param args [Array] Passed on to \{Kernel.puts}
def puts(*args)
return if @options[:for_engine][:quiet]
Kernel.puts(*args)
end

# Wraps the given string in terminal escapes
# causing it to have the given color.
# If terminal esapes aren't supported on this platform,
Expand Down Expand Up @@ -300,7 +309,7 @@ def set_opts(opts)
'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
@options[:for_engine][:style] = name.to_sym
end
opts.on('-q', '--quiet', 'Silence warnings during compilation.') do
opts.on('-q', '--quiet', 'Silence warnings and status messages during compilation.') do
@options[:for_engine][:quiet] = true
end
opts.on('-g', '--debug-info',
Expand Down
14 changes: 7 additions & 7 deletions lib/haml/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ class BaseEle
# @private
HAML_TAGS = %w[haml:block haml:loud haml:silent]

Hpricot::ElementContent.keys.each do |k|
HAML_TAGS.each do |el|
val = Hpricot::ElementContent[k]
val[el.hash] = true if val.is_a?(Hash)
end
end

HAML_TAGS.each do |t|
Hpricot::ElementContent[t] = {}
Hpricot::ElementContent.keys.each do |key|
Hpricot::ElementContent[t][key.hash] = true
end
end

Hpricot::ElementContent.keys.each do |k|
HAML_TAGS.each do |el|
val = Hpricot::ElementContent[k]
val[el.hash] = true if val.is_a?(Hash)
end
end

module Haml
# Converts HTML documents into Haml templates.
# Depends on [Hpricot](http://github.com/whymirror/hpricot) for HTML parsing.
Expand Down
19 changes: 18 additions & 1 deletion lib/haml/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module Util
# @api public
RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}

# The Ruby engine we're running under. Defaults to `"ruby"`
# if the top-level constant is undefined.
# @api public
RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"

# Returns the path of a file relative to the Haml root directory.
#
# @param file [String] The filename relative to the Haml root
Expand Down Expand Up @@ -415,13 +420,25 @@ def windows?
RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
end

# Whether or not this is running on IronRuby.
#
# @return [Boolean]
def ironruby?
RUBY_ENGINE == "ironruby"
end

## Cross-Ruby-Version Compatibility

# Whether or not this is running under Ruby 1.8 or lower.
#
# Note that IronRuby counts as Ruby 1.8,
# because it doesn't support the Ruby 1.9 encoding API.
#
# @return [Boolean]
def ruby1_8?
Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9
# IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
# We have to fall back to 1.8 behavior.
ironruby? || (Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9)
end

# Whether or not this is running under Ruby 1.8.6 or lower.
Expand Down
2 changes: 1 addition & 1 deletion lib/sass/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def tabulate(string)
comment_tab_str = nil
first = true
lines = []
string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/).each_with_index do |line, index|
string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^[^\n]*?$/).each_with_index do |line, index|
index += (@options[:line] || 1)
if line.strip.empty?
lines.last.text << "\n" if lines.last && lines.last.comment?
Expand Down
2 changes: 1 addition & 1 deletion lib/sass/script/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Lexer
:number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
:color => HEXCOLOR,
:bool => /(true|false)\b/,
:ident_op => %r{(#{Regexp.union(*IDENT_OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + "(?!#{NMCHAR}|$)")})})},
:ident_op => %r{(#{Regexp.union(*IDENT_OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + "(?!#{NMCHAR}|\Z)")})})},
:op => %r{(#{Regexp.union(*OP_NAMES)})},
}

Expand Down
6 changes: 3 additions & 3 deletions lib/sass/tree/root_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(template)
def to_s(*args)
super
rescue Sass::SyntaxError => e
e.sass_template = @template
e.sass_template ||= @template
raise e
end

Expand All @@ -36,7 +36,7 @@ def perform(environment)
environment.options = @options if environment.options.nil? || environment.options.empty?
super
rescue Sass::SyntaxError => e
e.sass_template = @template
e.sass_template ||= @template
raise e
end

Expand All @@ -49,7 +49,7 @@ def perform(environment)
def cssize(extends = Haml::Util::SubsetMap.new, parent = nil)
return super(extends, parent), extends
rescue Sass::SyntaxError => e
e.sass_template = @template
e.sass_template ||= @template
raise e
end

Expand Down
14 changes: 14 additions & 0 deletions test/haml/html2haml/erb_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,20 @@ def test_tag_inside_block
<tr></tr>
<% end %>
</table>
ERB
end

def test_silent_inside_block_inside_tag
assert_equal(<<HAML.rstrip, render_erb(<<ERB))
%table
- foo.each do
- haml_puts "foo"
HAML
<table>
<% foo.each do %>
<% haml_puts "foo" %>
<% end %>
</table>
ERB
end
end
20 changes: 20 additions & 0 deletions test/sass/scss/scss_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,26 @@ def test_if_error_line
assert_raise_line(2) {render(<<SCSS)}
@if true {foo: bar}
}
SCSS
end

def test_multiline_var
assert_equal <<CSS, render(<<SCSS)
foo {
a: 3;
b: false;
c: a b c; }
CSS
foo {
$var1: 1 +
2;
$var2: true and
false;
$var3: a b
c;
a: $var1;
b: $var2;
c: $var3; }
SCSS
end
end

0 comments on commit 5f06cdd

Please sign in to comment.