mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'master' into less2sass
This commit is contained in:
commit
6c1ab20523
15 changed files with 167 additions and 63 deletions
24
Rakefile
24
Rakefile
|
@ -39,15 +39,19 @@ END
|
|||
|
||||
# ----- Packaging -----
|
||||
|
||||
require 'rake/gempackagetask'
|
||||
load scope('haml.gemspec')
|
||||
# Don't use Rake::GemPackageTast because we want prerequisites to run
|
||||
# before we load the gemspec.
|
||||
desc "Build all the packages."
|
||||
task :package => [:revision_file, :submodules] do
|
||||
load scope('haml.gemspec')
|
||||
Gem::Builder.new(HAML_GEMSPEC).build
|
||||
pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}"
|
||||
mkdir_p "pkg"
|
||||
verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
|
||||
|
||||
Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
|
||||
if Rake.application.top_level_tasks.include?('release')
|
||||
pkg.need_tar_gz = true
|
||||
pkg.need_tar_bz2 = true
|
||||
pkg.need_zip = true
|
||||
end
|
||||
sh %{rm -f pkg/#{pkg}.tar.gz}
|
||||
verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
|
||||
sh %{gzip pkg/#{pkg}.tar}
|
||||
end
|
||||
|
||||
task :revision_file do
|
||||
|
@ -62,8 +66,6 @@ task :revision_file do
|
|||
File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
|
||||
end
|
||||
end
|
||||
Rake::Task[:package].prerequisites.insert(0, :revision_file)
|
||||
Rake::Task[:package].prerequisites.insert(0, :submodules)
|
||||
|
||||
# We also need to get rid of this file after packaging.
|
||||
at_exit { File.delete(scope('REVISION')) rescue nil }
|
||||
|
@ -81,8 +83,6 @@ task :release => [:check_release, :release_elpa, :package] do
|
|||
version = File.read(scope("VERSION")).strip
|
||||
sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
|
||||
sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
|
||||
sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
|
||||
sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
|
||||
sh %{gem push pkg/haml-#{version}.gem}
|
||||
end
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
3.0.0.rc.2
|
||||
3.0.0.rc.3
|
||||
|
|
|
@ -3,7 +3,16 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 3.0.0.rc.3 (Unreleased)
|
||||
## 3.0.0.rc.4 (Unreleased)
|
||||
|
||||
### Rails Beta Support
|
||||
|
||||
* Setting options via `Haml::Template.options` in the initializer
|
||||
now works without using `ActiveSupport.on_load(:action_view)`.
|
||||
|
||||
## 3.0.0.rc.3
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.3).
|
||||
|
||||
### Rails Beta Support
|
||||
|
||||
|
|
|
@ -3,7 +3,38 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 3.0.0.rc.3 (Unreleased)
|
||||
## 3.0.0.rc.4 (Unreleased)
|
||||
|
||||
* Don't check stylesheets for each request when running tests in Rails.
|
||||
This should speed up some tests significantly.
|
||||
|
||||
* Don't add extra newlines between variables with `sass-convert`.
|
||||
|
||||
## 3.0.0.rc.3
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.3).
|
||||
|
||||
### `@extend` Support
|
||||
|
||||
It's now possible to create a loop of `@extend` relations.
|
||||
For example,
|
||||
|
||||
.blueLink {
|
||||
color: blue;
|
||||
@extend .link; }
|
||||
|
||||
.link {
|
||||
font-weight: bold;
|
||||
@extend .blueLink; }
|
||||
|
||||
Before, this would have raised an error.
|
||||
Now it produces the following CSS:
|
||||
|
||||
.link, .blueLink {
|
||||
color: blue; }
|
||||
|
||||
.blueLink, .link {
|
||||
font-weight: bold; }
|
||||
|
||||
### Rails Beta Support
|
||||
|
||||
|
@ -20,6 +51,8 @@ The Sass Rails plugin now works using Rack middleware by default.
|
|||
|
||||
* Don't die when given a 70 kb property.
|
||||
|
||||
* `sass --watch` now works with a single file on OS X.
|
||||
|
||||
## 3.0.0.rc.2
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.2).
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
# Rails 3.0.0.beta.2+
|
||||
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
||||
require 'haml/template/options'
|
||||
ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
require 'haml/template/options'
|
||||
require 'haml/engine'
|
||||
require 'haml/helpers/action_view_mods'
|
||||
require 'haml/helpers/action_view_extensions'
|
||||
|
@ -5,15 +6,6 @@ require 'haml/helpers/action_view_extensions'
|
|||
module Haml
|
||||
# The class that keeps track of the global options for Haml within Rails.
|
||||
module Template
|
||||
extend self
|
||||
|
||||
@options = {}
|
||||
# The options hash for Haml when used within Rails.
|
||||
# See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
|
||||
#
|
||||
# @return [{Symbol => Object}]
|
||||
attr_accessor :options
|
||||
|
||||
# Enables integration with the Rails 2.2.5+ XSS protection,
|
||||
# if it's available and enabled.
|
||||
#
|
||||
|
|
16
lib/haml/template/options.rb
Normal file
16
lib/haml/template/options.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# We keep options in its own self-contained file
|
||||
# so that we can load it independently in Rails 3,
|
||||
# where the full template stuff is lazy-loaded.
|
||||
|
||||
module Haml
|
||||
module Template
|
||||
extend self
|
||||
|
||||
@options = {}
|
||||
# The options hash for Haml when used within Rails.
|
||||
# See {file:HAML_REFERENCE.md#haml_options the Haml options documentation}.
|
||||
#
|
||||
# @return [{Symbol => Object}]
|
||||
attr_accessor :options
|
||||
end
|
||||
end
|
|
@ -291,6 +291,15 @@ module Sass
|
|||
raise e
|
||||
end
|
||||
|
||||
unless individual_files.empty? && FSSM::Backends::Default.name == "FSSM::Backends::FSEvents"
|
||||
# As of FSSM 0.1.4, it doesn't support FSevents on individual files,
|
||||
# but it also isn't smart enough to switch to polling itself.
|
||||
require 'fssm/backends/polling'
|
||||
Haml::Util.silence_warnings do
|
||||
FSSM::Backends.const_set(:Default, FSSM::Backends::Polling)
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Keep better track of what depends on what
|
||||
# so we don't have to run a global update every time anything changes.
|
||||
FSSM.monitor do |mon|
|
||||
|
|
|
@ -4,7 +4,7 @@ unless defined?(Sass::RAILS_LOADED)
|
|||
Sass::Plugin.options.merge!(:template_location => Haml::Util.rails_root + '/public/stylesheets/sass',
|
||||
:css_location => Haml::Util.rails_root + '/public/stylesheets',
|
||||
:cache_location => Haml::Util.rails_root + '/tmp/sass-cache',
|
||||
:always_check => Haml::Util.rails_env != "production",
|
||||
:always_check => Haml::Util.rails_env == "development",
|
||||
:quiet => Haml::Util.rails_env != "production",
|
||||
:full_exception => Haml::Util.rails_env != "production")
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ module Sass
|
|||
# by extending this selector with `extends`.
|
||||
# These correspond to a {CommaSequence}'s {CommaSequence#members members array}.
|
||||
# @see CommaSequence#do_extend
|
||||
def do_extend(extends, supers = [])
|
||||
def do_extend(extends, seen = Set.new)
|
||||
paths = Haml::Util.paths(members.map do |sseq_or_op|
|
||||
next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence)
|
||||
extended = sseq_or_op.do_extend(extends, supers)
|
||||
extended = sseq_or_op.do_extend(extends, seen)
|
||||
choices = extended.map {|seq| seq.members}
|
||||
choices.unshift([sseq_or_op]) unless extended.any? {|seq| seq.superselector?(sseq_or_op)}
|
||||
choices
|
||||
|
|
|
@ -61,7 +61,7 @@ module Sass
|
|||
# @return [Array<Sequence>] A list of selectors generated
|
||||
# by extending this selector with `extends`.
|
||||
# @see CommaSequence#do_extend
|
||||
def do_extend(extends, supers = [])
|
||||
def do_extend(extends, seen = Set.new)
|
||||
extends.get(members.to_set).map do |seq, sels|
|
||||
# If A {@extend B} and C {...},
|
||||
# seq is A, sels is B, and self is C
|
||||
|
@ -69,13 +69,10 @@ module Sass
|
|||
self_without_sel = self.members - sels
|
||||
next unless unified = seq.members.last.unify(self_without_sel)
|
||||
[sels, seq.members[0...-1] + [unified]]
|
||||
end.compact.map {|sels, seq| [sels, Sequence.new(seq)]}.map do |sels, seq|
|
||||
seqs = seq.do_extend(extends, supers.unshift(sels))
|
||||
supers.shift
|
||||
seqs
|
||||
end.compact.map do |sels, seq|
|
||||
seq = Sequence.new(seq)
|
||||
seen.include?(sels) ? [] : seq.do_extend(extends, seen + [sels])
|
||||
end.flatten.uniq
|
||||
rescue SystemStackError
|
||||
handle_extend_loop(supers)
|
||||
end
|
||||
|
||||
# Unifies this selector with another {SimpleSequence}'s {SimpleSequence#members members array},
|
||||
|
@ -140,33 +137,6 @@ module Sass
|
|||
other.class == self.class && other.base.eql?(self.base) &&
|
||||
Haml::Util.set_eql?(other.rest, self.rest)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Raise a {Sass::SyntaxError} describing a loop of `@extend` directives.
|
||||
#
|
||||
# @param supers [Array<Simple>] The stack of selectors that contains the loop,
|
||||
# ordered from deepest to most shallow.
|
||||
# @raise [Sass::SyntaxError] Describing the loop
|
||||
def handle_extend_loop(supers)
|
||||
supers.inject([]) do |sseqs, sseq|
|
||||
next sseqs.push(sseq) unless sseqs.first.eql?(sseq)
|
||||
conses = Haml::Util.enum_cons(sseqs.push(sseq), 2).to_a
|
||||
_, i = Haml::Util.enum_with_index(conses).max do |((_, sseq1), _), ((_, sseq2), _)|
|
||||
sseq1.first.line <=> sseq2.first.line
|
||||
end
|
||||
loop = (conses[i..-1] + conses[0...i]).map do |sseq1, sseq2|
|
||||
sel1 = SimpleSequence.new(sseq1).inspect
|
||||
sel2 = SimpleSequence.new(sseq2).inspect
|
||||
str = " #{sel1} extends #{sel2} on line #{sseq2.first.line}"
|
||||
str << " of " << sseq2.first.filename if sseq2.first.filename
|
||||
str
|
||||
end.join(",\n")
|
||||
raise Sass::SyntaxError.new("An @extend loop was found:\n#{loop}")
|
||||
end
|
||||
# Should never get here
|
||||
raise Sass::SyntaxError.new("An @extend loop exists, but the exact loop couldn't be found")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,8 @@ module Sass
|
|||
child.send("to_#{fmt}", 0, opts) +
|
||||
if nxt &&
|
||||
(child.is_a?(CommentNode) && child.line + child.value.count("\n") + 1 == nxt.line) ||
|
||||
(child.is_a?(ImportNode) && nxt.is_a?(ImportNode) && child.line + 1 == nxt.line)
|
||||
(child.is_a?(ImportNode) && nxt.is_a?(ImportNode) && child.line + 1 == nxt.line) ||
|
||||
(child.is_a?(VariableNode) && nxt.is_a?(VariableNode) && child.line + 1 == nxt.line)
|
||||
""
|
||||
else
|
||||
"\n"
|
||||
|
|
|
@ -888,6 +888,24 @@ SCSS
|
|||
assert_sass_to_scss '$var: 12px $bar baz !default;', '$var ||= 12px $bar "baz"'
|
||||
end
|
||||
|
||||
def test_multiple_variable_definitions
|
||||
assert_renders <<SASS, <<SCSS
|
||||
$var1: foo
|
||||
$var2: bar
|
||||
$var3: baz
|
||||
|
||||
$var4: bip
|
||||
$var5: bap
|
||||
SASS
|
||||
$var1: foo;
|
||||
$var2: bar;
|
||||
$var3: baz;
|
||||
|
||||
$var4: bip;
|
||||
$var5: bap;
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_division_asserted_with_parens
|
||||
assert_renders <<SASS, <<SCSS
|
||||
foo
|
||||
|
|
|
@ -1100,6 +1100,61 @@ CSS
|
|||
SCSS
|
||||
end
|
||||
|
||||
# Loops
|
||||
|
||||
def test_extend_self_loop
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.foo {
|
||||
a: b; }
|
||||
CSS
|
||||
.foo {a: b; @extend .foo}
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_basic_extend_loop
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.bar, .foo {
|
||||
a: b; }
|
||||
|
||||
.foo, .bar {
|
||||
c: d; }
|
||||
CSS
|
||||
.foo {a: b; @extend .bar}
|
||||
.bar {c: d; @extend .foo}
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_three_level_extend_loop
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.baz, .bar, .foo {
|
||||
a: b; }
|
||||
|
||||
.foo, .baz, .bar {
|
||||
c: d; }
|
||||
|
||||
.bar, .foo, .baz {
|
||||
e: f; }
|
||||
CSS
|
||||
.foo {a: b; @extend .bar}
|
||||
.bar {c: d; @extend .baz}
|
||||
.baz {e: f; @extend .foo}
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_nested_extend_loop
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.bar, .bar .foo {
|
||||
a: b; }
|
||||
.bar .foo, .bar .foo .foo {
|
||||
c: d; }
|
||||
CSS
|
||||
.bar {
|
||||
a: b;
|
||||
.foo {c: d; @extend .bar}
|
||||
}
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_multiple_extender_merges_with_superset_selector
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
a.bar.baz, a.foo {
|
||||
|
|
2
vendor/fssm
vendored
2
vendor/fssm
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f4b896724e0bf102a162001840ca2975eab21b02
|
||||
Subproject commit 116ffbea3de69c6c72398b0514f057cabf65cdbb
|
Loading…
Add table
Reference in a new issue