haml-edge 3.1.17 → 3.1.18
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/exec.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +3 -1
- data/lib/sass/script/interpolation.rb +9 -2
- data/lib/sass/script/lexer.rb +5 -4
- data/lib/sass/script/parser.rb +30 -4
- data/test/linked_rails.rb +7 -0
- data/test/sass/plugin_test.rb +0 -29
- data/test/sass/script_conversion_test.rb +43 -0
- data/test/sass/script_test.rb +57 -1
- data/test/sass/scss/scss_test.rb +0 -48
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.18
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.18
|
data/lib/haml/exec.rb
CHANGED
@@ -85,7 +85,9 @@ module ActionView
|
|
85
85
|
module CaptureHelper
|
86
86
|
def capture_with_haml(*args, &block)
|
87
87
|
if Haml::Helpers.block_is_haml?(block)
|
88
|
-
capture_haml(*args, &block)
|
88
|
+
str = capture_haml(*args, &block)
|
89
|
+
return ActionView::NonConcattingString.new(str) if defined?(ActionView::NonConcattingString)
|
90
|
+
return str
|
89
91
|
else
|
90
92
|
capture_without_haml(*args, &block)
|
91
93
|
end
|
@@ -10,12 +10,17 @@ module Sass::Script
|
|
10
10
|
# @param after [Node] The SassScript after the interpolation
|
11
11
|
# @param wb [Boolean] Whether there was whitespace between `before` and `#{`
|
12
12
|
# @param wa [Boolean] Whether there was whitespace between `}` and `after`
|
13
|
-
|
13
|
+
# @param originally_text [Boolean]
|
14
|
+
# Whether the original format of the interpolation was plain text,
|
15
|
+
# not an interpolation.
|
16
|
+
# This is used when converting back to SassScript.
|
17
|
+
def initialize(before, mid, after, wb, wa, originally_text = false)
|
14
18
|
@before = before
|
15
19
|
@mid = mid
|
16
20
|
@after = after
|
17
21
|
@whitespace_before = wb
|
18
22
|
@whitespace_after = wa
|
23
|
+
@originally_text = originally_text
|
19
24
|
end
|
20
25
|
|
21
26
|
# @return [String] A human-readable s-expression representation of the interpolation
|
@@ -28,7 +33,9 @@ module Sass::Script
|
|
28
33
|
res = ""
|
29
34
|
res << @before.to_sass(opts) if @before
|
30
35
|
res << ' ' if @before && @whitespace_before
|
31
|
-
res << '#{'
|
36
|
+
res << '#{' unless @originally_text
|
37
|
+
res << @mid.to_sass(opts)
|
38
|
+
res << '}' unless @originally_text
|
32
39
|
res << ' ' if @after && @whitespace_after
|
33
40
|
res << @after.to_sass(opts) if @after
|
34
41
|
res
|
data/lib/sass/script/lexer.rb
CHANGED
@@ -175,6 +175,11 @@ module Sass
|
|
175
175
|
@scanner.eos? && @tok.nil?
|
176
176
|
end
|
177
177
|
|
178
|
+
# @return [Boolean] Whether or not the last token lexed was `:end_interpolation`.
|
179
|
+
def after_interpolation?
|
180
|
+
@prev && @prev.type == :end_interpolation
|
181
|
+
end
|
182
|
+
|
178
183
|
# Raise an error to the effect that `name` was expected in the input stream
|
179
184
|
# and wasn't found.
|
180
185
|
#
|
@@ -327,10 +332,6 @@ MESSAGE
|
|
327
332
|
def current_position
|
328
333
|
@offset + 1
|
329
334
|
end
|
330
|
-
|
331
|
-
def after_interpolation?
|
332
|
-
@prev && @prev.type == :end_interpolation
|
333
|
-
end
|
334
335
|
end
|
335
336
|
end
|
336
337
|
end
|
data/lib/sass/script/parser.rb
CHANGED
@@ -150,8 +150,10 @@ module Sass
|
|
150
150
|
def production(name, sub, *ops)
|
151
151
|
class_eval <<RUBY
|
152
152
|
def #{name}
|
153
|
+
interp = try_ops_after_interp(#{ops.inspect}, #{name.inspect}) and return interp
|
153
154
|
return unless e = #{sub}
|
154
155
|
while tok = try_tok(#{ops.map {|o| o.inspect}.join(', ')})
|
156
|
+
interp = try_op_before_interp(tok, e) and return interp
|
155
157
|
line = @lexer.line
|
156
158
|
e = Operation.new(e, assert_expr(#{sub.inspect}), tok.type)
|
157
159
|
e.line = line
|
@@ -164,8 +166,9 @@ RUBY
|
|
164
166
|
def unary(op, sub)
|
165
167
|
class_eval <<RUBY
|
166
168
|
def unary_#{op}
|
167
|
-
return #{sub} unless try_tok(:#{op})
|
168
|
-
|
169
|
+
return #{sub} unless tok = try_tok(:#{op})
|
170
|
+
interp = try_op_before_interp(tok) and return interp
|
171
|
+
line = @lexer.line
|
169
172
|
op = UnaryOperation.new(assert_expr(:unary_#{op}), :#{op})
|
170
173
|
op.line = line
|
171
174
|
op
|
@@ -182,8 +185,31 @@ RUBY
|
|
182
185
|
production :expr, :interpolation, :comma
|
183
186
|
production :equals, :interpolation, :single_eq
|
184
187
|
|
185
|
-
def
|
186
|
-
|
188
|
+
def try_op_before_interp(op, prev = nil)
|
189
|
+
return unless @lexer.peek.type == :begin_interpolation
|
190
|
+
wb = @lexer.whitespace?(op)
|
191
|
+
str = Script::String.new(Lexer::OPERATORS_REVERSE[op.type])
|
192
|
+
str.line = @lexer.line
|
193
|
+
interp = Script::Interpolation.new(prev, str, nil, wb, !:wa, :originally_text)
|
194
|
+
interp.line = @lexer.line
|
195
|
+
interpolation(interp)
|
196
|
+
end
|
197
|
+
|
198
|
+
def try_ops_after_interp(ops, name)
|
199
|
+
return unless @lexer.after_interpolation?
|
200
|
+
return unless op = try_tok(*ops)
|
201
|
+
interp = try_op_before_interp(op) and return interp
|
202
|
+
|
203
|
+
wa = @lexer.whitespace?
|
204
|
+
str = Script::String.new(Lexer::OPERATORS_REVERSE[op.type])
|
205
|
+
str.line = @lexer.line
|
206
|
+
interp = Script::Interpolation.new(nil, str, assert_expr(name), !:wb, wa, :originally_text)
|
207
|
+
interp.line = @lexer.line
|
208
|
+
return interp
|
209
|
+
end
|
210
|
+
|
211
|
+
def interpolation(first = concat)
|
212
|
+
e = first
|
187
213
|
while interp = try_tok(:begin_interpolation)
|
188
214
|
wb = @lexer.whitespace?(interp)
|
189
215
|
line = @lexer.line
|
data/test/linked_rails.rb
CHANGED
@@ -17,6 +17,13 @@ begin
|
|
17
17
|
rescue LoadError
|
18
18
|
end
|
19
19
|
|
20
|
+
if defined?(Rails::Application) # Rails 3
|
21
|
+
class TestApp < Rails::Application
|
22
|
+
config.root = File.join(File.dirname(__FILE__), "../..")
|
23
|
+
end
|
24
|
+
Rails.application = TestApp
|
25
|
+
end
|
26
|
+
|
20
27
|
ActionController::Base.logger = Logger.new(nil)
|
21
28
|
|
22
29
|
# Load plugins from test/plugins.
|
data/test/sass/plugin_test.rb
CHANGED
@@ -115,35 +115,6 @@ CSS
|
|
115
115
|
assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
|
116
116
|
end
|
117
117
|
|
118
|
-
def test_merb_update
|
119
|
-
begin
|
120
|
-
require 'merb'
|
121
|
-
rescue LoadError
|
122
|
-
puts "\nmerb couldn't be loaded, skipping a test"
|
123
|
-
return
|
124
|
-
end
|
125
|
-
|
126
|
-
require 'sass/plugin/merb'
|
127
|
-
if defined?(MerbHandler)
|
128
|
-
MerbHandler.send(:define_method, :process_without_sass) { |*args| }
|
129
|
-
else
|
130
|
-
Merb::Rack::Application.send(:define_method, :call_without_sass) { |*args| }
|
131
|
-
end
|
132
|
-
|
133
|
-
set_plugin_opts
|
134
|
-
|
135
|
-
File.delete(tempfile_loc('basic'))
|
136
|
-
assert_needs_update 'basic'
|
137
|
-
|
138
|
-
if defined?(MerbHandler)
|
139
|
-
MerbHandler.new('.').process nil, nil
|
140
|
-
else
|
141
|
-
Merb::Rack::Application.new.call(::Rack::MockRequest.env_for('/'))
|
142
|
-
end
|
143
|
-
|
144
|
-
assert_stylesheet_updated 'basic'
|
145
|
-
end
|
146
|
-
|
147
118
|
def test_doesnt_render_partials
|
148
119
|
assert !File.exists?(tempfile_loc('_partial'))
|
149
120
|
end
|
@@ -158,6 +158,49 @@ RUBY
|
|
158
158
|
assert_renders "\#{$bar}"
|
159
159
|
end
|
160
160
|
|
161
|
+
def test_interpolation_in_function
|
162
|
+
assert_renders 'flabnabbit(#{1 + "foo"})'
|
163
|
+
assert_renders 'flabnabbit($foo #{1 + "foo"}$baz)'
|
164
|
+
assert_renders 'flabnabbit($foo #{1 + "foo"}#{2 + "bar"} $baz)'
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_interpolation_near_operators
|
168
|
+
assert_renders '#{1 + 2} , #{3 + 4}'
|
169
|
+
assert_renders '#{1 + 2}, #{3 + 4}'
|
170
|
+
assert_renders '#{1 + 2} ,#{3 + 4}'
|
171
|
+
assert_renders '#{1 + 2},#{3 + 4}'
|
172
|
+
|
173
|
+
assert_renders '3 / #{3 + 4}'
|
174
|
+
assert_renders '3 /#{3 + 4}'
|
175
|
+
assert_renders '3/ #{3 + 4}'
|
176
|
+
assert_renders '3/#{3 + 4}'
|
177
|
+
|
178
|
+
assert_renders '#{1 + 2} * 7'
|
179
|
+
assert_renders '#{1 + 2}* 7'
|
180
|
+
assert_renders '#{1 + 2} *7'
|
181
|
+
assert_renders '#{1 + 2}*7'
|
182
|
+
|
183
|
+
assert_renders '-#{1 + 2}'
|
184
|
+
assert_renders '- #{1 + 2}'
|
185
|
+
|
186
|
+
assert_renders '5 + #{1 + 2} * #{3 + 4}'
|
187
|
+
assert_renders '5 +#{1 + 2} * #{3 + 4}'
|
188
|
+
assert_renders '5+#{1 + 2} * #{3 + 4}'
|
189
|
+
assert_renders '#{1 + 2} * #{3 + 4} + 5'
|
190
|
+
assert_renders '#{1 + 2} * #{3 + 4}+ 5'
|
191
|
+
assert_renders '#{1 + 2} * #{3 + 4}+5'
|
192
|
+
|
193
|
+
assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 / (#{1 + 2} + #{3 + 4})')
|
194
|
+
assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 /(#{1 + 2} + #{3 + 4})')
|
195
|
+
assert_equal '5 / #{1 + 2} + #{3 + 4}', render('5 /( #{1 + 2} + #{3 + 4} )')
|
196
|
+
assert_equal '#{1 + 2} + #{3 + 4} / 5', render('(#{1 + 2} + #{3 + 4}) / 5')
|
197
|
+
assert_equal '#{1 + 2} + #{3 + 4} / 5', render('(#{1 + 2} + #{3 + 4})/ 5')
|
198
|
+
assert_equal '#{1 + 2} + #{3 + 4} / 5', render('( #{1 + 2} + #{3 + 4} )/ 5')
|
199
|
+
|
200
|
+
assert_renders '#{1 + 2} + 2 + 3'
|
201
|
+
assert_renders '#{1 + 2} +2 + 3'
|
202
|
+
end
|
203
|
+
|
161
204
|
def test_string_interpolation
|
162
205
|
assert_renders '"foo#{$bar}baz"'
|
163
206
|
assert_renders '"foo #{$bar}baz"'
|
data/test/sass/script_test.rb
CHANGED
@@ -97,7 +97,63 @@ class SassScriptTest < Test::Unit::TestCase
|
|
97
97
|
assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
100
|
+
def test_basic_interpolation
|
101
|
+
assert_equal "foo3bar", resolve("foo\#{1 + 2}bar")
|
102
|
+
assert_equal "foo3 bar", resolve("foo\#{1 + 2} bar")
|
103
|
+
assert_equal "foo 3bar", resolve("foo \#{1 + 2}bar")
|
104
|
+
assert_equal "foo 3 bar", resolve("foo \#{1 + 2} bar")
|
105
|
+
assert_equal "foo 35 bar", resolve("foo \#{1 + 2}\#{2 + 3} bar")
|
106
|
+
assert_equal "foo 3 5 bar", resolve("foo \#{1 + 2} \#{2 + 3} bar")
|
107
|
+
assert_equal "3bar", resolve("\#{1 + 2}bar")
|
108
|
+
assert_equal "foo3", resolve("foo\#{1 + 2}")
|
109
|
+
assert_equal "3", resolve("\#{1 + 2}")
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_interpolation_in_function
|
113
|
+
assert_equal 'flabnabbit(1foo)', resolve('flabnabbit(#{1 + "foo"})')
|
114
|
+
assert_equal 'flabnabbit(foo 1foobaz)', resolve('flabnabbit(foo #{1 + "foo"}baz)')
|
115
|
+
assert_equal('flabnabbit(foo 1foo2bar baz)',
|
116
|
+
resolve('flabnabbit(foo #{1 + "foo"}#{2 + "bar"} baz)'))
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_interpolation_near_operators
|
120
|
+
assert_equal '3 , 7', resolve('#{1 + 2} , #{3 + 4}')
|
121
|
+
assert_equal '3, 7', resolve('#{1 + 2}, #{3 + 4}')
|
122
|
+
assert_equal '3 ,7', resolve('#{1 + 2} ,#{3 + 4}')
|
123
|
+
assert_equal '3,7', resolve('#{1 + 2},#{3 + 4}')
|
124
|
+
|
125
|
+
assert_equal '3 / 7', resolve('3 / #{3 + 4}')
|
126
|
+
assert_equal '3 /7', resolve('3 /#{3 + 4}')
|
127
|
+
assert_equal '3/ 7', resolve('3/ #{3 + 4}')
|
128
|
+
assert_equal '3/7', resolve('3/#{3 + 4}')
|
129
|
+
|
130
|
+
assert_equal '3 * 7', resolve('#{1 + 2} * 7')
|
131
|
+
assert_equal '3* 7', resolve('#{1 + 2}* 7')
|
132
|
+
assert_equal '3 *7', resolve('#{1 + 2} *7')
|
133
|
+
assert_equal '3*7', resolve('#{1 + 2}*7')
|
134
|
+
|
135
|
+
assert_equal '-3', resolve('-#{1 + 2}')
|
136
|
+
assert_equal '- 3', resolve('- #{1 + 2}')
|
137
|
+
|
138
|
+
assert_equal '5 + 3 * 7', resolve('5 + #{1 + 2} * #{3 + 4}')
|
139
|
+
assert_equal '5 +3 * 7', resolve('5 +#{1 + 2} * #{3 + 4}')
|
140
|
+
assert_equal '5+3 * 7', resolve('5+#{1 + 2} * #{3 + 4}')
|
141
|
+
assert_equal '3 * 7 + 5', resolve('#{1 + 2} * #{3 + 4} + 5')
|
142
|
+
assert_equal '3 * 7+ 5', resolve('#{1 + 2} * #{3 + 4}+ 5')
|
143
|
+
assert_equal '3 * 7+5', resolve('#{1 + 2} * #{3 + 4}+5')
|
144
|
+
|
145
|
+
assert_equal '5/3 + 7', resolve('5 / (#{1 + 2} + #{3 + 4})')
|
146
|
+
assert_equal '5/3 + 7', resolve('5 /(#{1 + 2} + #{3 + 4})')
|
147
|
+
assert_equal '5/3 + 7', resolve('5 /( #{1 + 2} + #{3 + 4} )')
|
148
|
+
assert_equal '3 + 7/5', resolve('(#{1 + 2} + #{3 + 4}) / 5')
|
149
|
+
assert_equal '3 + 7/5', resolve('(#{1 + 2} + #{3 + 4})/ 5')
|
150
|
+
assert_equal '3 + 7/5', resolve('( #{1 + 2} + #{3 + 4} )/ 5')
|
151
|
+
|
152
|
+
assert_equal '3 + 5', resolve('#{1 + 2} + 2 + 3')
|
153
|
+
assert_equal '3 +5', resolve('#{1 + 2} +2 + 3')
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_string_interpolation
|
101
157
|
assert_equal "foo bar, baz bang", resolve('"foo #{"bar"}, #{"baz"} bang"')
|
102
158
|
assert_equal "foo bar baz bang", resolve('"foo #{"#{"ba" + "r"} baz"} bang"')
|
103
159
|
assert_equal 'foo #{bar baz} bang', resolve('"foo \#{#{"ba" + "r"} baz} bang"')
|
data/test/sass/scss/scss_test.rb
CHANGED
@@ -727,54 +727,6 @@ div { -foo-\#{$a}-\#{$b}-foo: foo }
|
|
727
727
|
SCSS
|
728
728
|
end
|
729
729
|
|
730
|
-
def test_basic_prop_val_interpolation
|
731
|
-
assert_equal <<CSS, render(<<SCSS)
|
732
|
-
foo {
|
733
|
-
bar: foo 3 baz; }
|
734
|
-
CSS
|
735
|
-
foo {bar: foo \#{1 + 2} baz}
|
736
|
-
SCSS
|
737
|
-
assert_equal <<CSS, render(<<SCSS)
|
738
|
-
foo {
|
739
|
-
bar: foo3 baz; }
|
740
|
-
CSS
|
741
|
-
foo {bar: foo\#{1 + 2} baz}
|
742
|
-
SCSS
|
743
|
-
assert_equal <<CSS, render(<<SCSS)
|
744
|
-
foo {
|
745
|
-
bar: foo 3, baz; }
|
746
|
-
CSS
|
747
|
-
foo {bar: foo \#{1 + 2},baz}
|
748
|
-
SCSS
|
749
|
-
end
|
750
|
-
|
751
|
-
def test_prop_val_only_interpolation
|
752
|
-
assert_equal <<CSS, render(<<SCSS)
|
753
|
-
foo {
|
754
|
-
bar: bazbang; }
|
755
|
-
CSS
|
756
|
-
foo {bar: \#{"baz" + "bang"}}
|
757
|
-
SCSS
|
758
|
-
end
|
759
|
-
|
760
|
-
def test_prop_val_interpolation_in_string
|
761
|
-
assert_equal <<CSS, render(<<SCSS)
|
762
|
-
foo {
|
763
|
-
bar: "bizzle bazbang bop"; }
|
764
|
-
CSS
|
765
|
-
foo {bar: "bizzle \#{"baz" + "bang"} bop"}
|
766
|
-
SCSS
|
767
|
-
end
|
768
|
-
|
769
|
-
def test_prop_val_interpolation_in_function
|
770
|
-
assert_equal <<CSS, render(<<SCSS)
|
771
|
-
foo {
|
772
|
-
bar: flabnabbit(1foo); }
|
773
|
-
CSS
|
774
|
-
foo {bar: flabnabbit(\#{1 + "foo"})}
|
775
|
-
SCSS
|
776
|
-
end
|
777
|
-
|
778
730
|
def test_basic_prop_name_interpolation
|
779
731
|
assert_equal <<CSS, render(<<SCSS)
|
780
732
|
foo {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-05-
|
14
|
+
date: 2010-05-19 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|