haml-edge 2.1.21 → 2.1.22
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/FAQ.md +142 -0
- data/{README.rdoc → README.md} +141 -141
- data/Rakefile +29 -17
- data/VERSION +1 -1
- data/lib/haml/buffer.rb +63 -27
- data/lib/haml/engine.rb +103 -80
- data/lib/haml/error.rb +7 -7
- data/lib/haml/exec.rb +80 -26
- data/lib/haml/filters.rb +106 -40
- data/lib/haml/helpers/action_view_extensions.rb +34 -39
- data/lib/haml/helpers/action_view_mods.rb +132 -139
- data/lib/haml/helpers.rb +207 -153
- data/lib/haml/html.rb +40 -21
- data/lib/haml/precompiler.rb +2 -0
- data/lib/haml/shared.rb +34 -3
- data/lib/haml/template/patch.rb +1 -1
- data/lib/haml/template/plugin.rb +0 -2
- data/lib/haml/template.rb +5 -0
- data/lib/haml/util.rb +136 -1
- data/lib/haml/version.rb +16 -4
- data/lib/haml.rb +502 -481
- data/lib/sass/css.rb +106 -68
- data/lib/sass/engine.rb +55 -22
- data/lib/sass/environment.rb +52 -21
- data/lib/sass/error.rb +23 -12
- data/lib/sass/files.rb +27 -0
- data/lib/sass/plugin/merb.rb +2 -2
- data/lib/sass/plugin/rails.rb +0 -2
- data/lib/sass/plugin.rb +32 -23
- data/lib/sass/repl.rb +7 -0
- data/lib/sass/script/bool.rb +9 -5
- data/lib/sass/script/color.rb +87 -1
- data/lib/sass/script/funcall.rb +23 -2
- data/lib/sass/script/functions.rb +93 -44
- data/lib/sass/script/lexer.rb +33 -3
- data/lib/sass/script/literal.rb +93 -1
- data/lib/sass/script/node.rb +14 -0
- data/lib/sass/script/number.rb +128 -4
- data/lib/sass/script/operation.rb +16 -1
- data/lib/sass/script/parser.rb +51 -21
- data/lib/sass/script/string.rb +7 -4
- data/lib/sass/script/unary_operation.rb +14 -1
- data/lib/sass/script/variable.rb +12 -1
- data/lib/sass/script.rb +26 -5
- data/lib/sass/tree/attr_node.rb +46 -9
- data/lib/sass/tree/comment_node.rb +41 -1
- data/lib/sass/tree/debug_node.rb +8 -0
- data/lib/sass/tree/directive_node.rb +20 -0
- data/lib/sass/tree/file_node.rb +12 -0
- data/lib/sass/tree/for_node.rb +15 -0
- data/lib/sass/tree/if_node.rb +22 -0
- data/lib/sass/tree/mixin_def_node.rb +12 -1
- data/lib/sass/tree/mixin_node.rb +13 -0
- data/lib/sass/tree/node.rb +136 -6
- data/lib/sass/tree/rule_node.rb +66 -7
- data/lib/sass/tree/variable_node.rb +10 -0
- data/lib/sass/tree/while_node.rb +11 -1
- data/lib/sass.rb +544 -534
- metadata +7 -6
- data/FAQ +0 -138
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -5,25 +5,77 @@ module Sass::Tree
|
|
5
5
|
# The character used to include the parent selector
|
6
6
|
PARENT = '&'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# The CSS selectors for this rule.
|
9
|
+
# Each string is a selector line, and the lines are meant to be separated by commas.
|
10
|
+
# For example,
|
11
|
+
#
|
12
|
+
# foo, bar, baz,
|
13
|
+
# bip, bop, bup
|
14
|
+
#
|
15
|
+
# would be
|
16
|
+
#
|
17
|
+
# ["foo, bar, baz",
|
18
|
+
# "bip, bop, bup"]
|
19
|
+
#
|
20
|
+
# @return [Array<String>]
|
21
|
+
attr_accessor :rules
|
22
|
+
|
23
|
+
# The CSS selectors for this rule,
|
24
|
+
# parsed for commas and parent-references.
|
25
|
+
# It's only set once {Tree::Node#perform} has been called.
|
26
|
+
#
|
27
|
+
# It's an array of arrays of arrays.
|
28
|
+
# The first level of arrays represents distinct lines in the Sass file;
|
29
|
+
# the second level represents comma-separated selectors;
|
30
|
+
# the third represents structure within those selectors,
|
31
|
+
# currently only parent-refs (represented by `:parent`).
|
32
|
+
# For example,
|
33
|
+
#
|
34
|
+
# &.foo, bar, baz,
|
35
|
+
# bip, &.bop, bup
|
36
|
+
#
|
37
|
+
# would be
|
38
|
+
#
|
39
|
+
# [[[:parent, "foo"], ["bar"], ["baz"]],
|
40
|
+
# [["bip"], [:parent, "bop"], ["bup"]]]
|
41
|
+
#
|
42
|
+
# @return [Array<Array<Array<String|Symbol>>>]
|
43
|
+
attr_accessor :parsed_rules
|
44
|
+
|
45
|
+
# @param rule [String] The first CSS rule. See \{#rules}
|
10
46
|
def initialize(rule)
|
11
47
|
@rules = [rule]
|
12
48
|
super()
|
13
49
|
end
|
14
50
|
|
51
|
+
# Compares the contents of two rules.
|
52
|
+
#
|
53
|
+
# @param other [Object] The object to compare with
|
54
|
+
# @return [Boolean] Whether or not this node and the other object
|
55
|
+
# are the same
|
15
56
|
def ==(other)
|
16
57
|
self.class == other.class && rules == other.rules && super
|
17
58
|
end
|
18
59
|
|
60
|
+
# Adds another {RuleNode}'s rules to this one's.
|
61
|
+
#
|
62
|
+
# @param node [RuleNode] The other node
|
19
63
|
def add_rules(node)
|
20
64
|
@rules += node.rules
|
21
65
|
end
|
22
66
|
|
67
|
+
# @return [Boolean] Whether or not this rule is continued on the next line
|
23
68
|
def continued?
|
24
69
|
@rules.last[-1] == ?,
|
25
70
|
end
|
26
71
|
|
72
|
+
# Computes the CSS for the rule.
|
73
|
+
#
|
74
|
+
# @param tabs [Fixnum] The level of indentation for the CSS
|
75
|
+
# @param super_rules [Array<Array<String>>] The rules for the parent node
|
76
|
+
# (see \{#rules}), or `nil` if there are no parents
|
77
|
+
# @return [String] The resulting CSS
|
78
|
+
# @raise [Sass::SyntaxError] if the rule has no parents but uses `&`
|
27
79
|
def to_s(tabs, super_rules = nil)
|
28
80
|
resolved_rules = resolve_parent_refs(super_rules)
|
29
81
|
|
@@ -94,6 +146,18 @@ module Sass::Tree
|
|
94
146
|
|
95
147
|
protected
|
96
148
|
|
149
|
+
# Runs any SassScript that may be embedded in the rule,
|
150
|
+
# and parses the selectors for commas.
|
151
|
+
#
|
152
|
+
# @param environment [Sass::Environment] The lexical environment containing
|
153
|
+
# variable and mixin values
|
154
|
+
def perform!(environment)
|
155
|
+
@parsed_rules = @rules.map {|r| parse_selector(interpolate(r, environment))}
|
156
|
+
super
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
|
97
161
|
def resolve_parent_refs(super_rules)
|
98
162
|
if super_rules.nil?
|
99
163
|
return @parsed_rules.map do |line|
|
@@ -127,11 +191,6 @@ module Sass::Tree
|
|
127
191
|
new_rules
|
128
192
|
end
|
129
193
|
|
130
|
-
def perform!(environment)
|
131
|
-
@parsed_rules = @rules.map {|r| parse_selector(interpolate(r, environment))}
|
132
|
-
super
|
133
|
-
end
|
134
|
-
|
135
194
|
def parse_selector(text)
|
136
195
|
scanner = StringScanner.new(text)
|
137
196
|
rules = [[]]
|
@@ -1,6 +1,12 @@
|
|
1
1
|
module Sass
|
2
2
|
module Tree
|
3
|
+
# A dynamic node representing a variable definition.
|
4
|
+
#
|
5
|
+
# @see Sass::Tree
|
3
6
|
class VariableNode < Node
|
7
|
+
# @param name [String] The name of the variable
|
8
|
+
# @param expr [Script::Node] The parse tree for the initial variable value
|
9
|
+
# @param guarded [Boolean] Whether this is a guarded variable assignment (`||=`)
|
4
10
|
def initialize(name, expr, guarded)
|
5
11
|
@name = name
|
6
12
|
@expr = expr
|
@@ -10,6 +16,10 @@ module Sass
|
|
10
16
|
|
11
17
|
protected
|
12
18
|
|
19
|
+
# Loads the new variable value into the environment.
|
20
|
+
#
|
21
|
+
# @param environment [Sass::Environment] The lexical environment containing
|
22
|
+
# variable and mixin values
|
13
23
|
def _perform(environment)
|
14
24
|
if @guarded && environment.var(@name).nil?
|
15
25
|
environment.set_var(@name, @expr.perform(environment))
|
data/lib/sass/tree/while_node.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
require 'sass/tree/node'
|
2
2
|
|
3
3
|
module Sass::Tree
|
4
|
+
# A dynamic node representing a Sass `@while` loop.
|
5
|
+
#
|
6
|
+
# @see Sass::Tree
|
4
7
|
class WhileNode < Node
|
8
|
+
# @param expr [Script::Node] The parse tree for the continue expression
|
5
9
|
def initialize(expr)
|
6
10
|
@expr = expr
|
7
11
|
super()
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
protected
|
11
15
|
|
16
|
+
# Runs the child nodes until the continue expression becomes false.
|
17
|
+
#
|
18
|
+
# @param environment [Sass::Environment] The lexical environment containing
|
19
|
+
# variable and mixin values
|
20
|
+
# @return [Array<Tree::Node>] The resulting static nodes
|
21
|
+
# @see Sass::Tree
|
12
22
|
def _perform(environment)
|
13
23
|
children = []
|
14
24
|
new_environment = Sass::Environment.new(environment)
|