haml-edge 2.3.58 → 2.3.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/precompiler.rb +4 -4
- data/lib/haml/util.rb +13 -1
- data/lib/sass/script/functions.rb +1 -1
- data/test/haml/helper_test.rb +1 -1
- data/test/haml/util_test.rb +8 -0
- data/test/test_helper.rb +1 -1
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.3.
|
|
1
|
+
2.3.59
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.3.
|
|
1
|
+
2.3.59
|
data/lib/haml/precompiler.rb
CHANGED
|
@@ -361,14 +361,14 @@ END
|
|
|
361
361
|
|
|
362
362
|
no_format = @options[:ugly] &&
|
|
363
363
|
!(opts[:preserve_script] || opts[:preserve_tag] || opts[:escape_html])
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
output_expr = "(#{text}\n)"
|
|
365
|
+
static_method = "_hamlout.#{static_method_name(:format_script, *args)}"
|
|
366
366
|
|
|
367
367
|
# Prerender tabulation unless we're in a tag
|
|
368
368
|
push_merged_text '' unless opts[:in_tag]
|
|
369
369
|
|
|
370
370
|
unless block_opened?
|
|
371
|
-
@to_merge << [:script, no_format ? "#{text}\n" : "
|
|
371
|
+
@to_merge << [:script, no_format ? "#{text}\n" : "#{static_method}(#{output_expr});"]
|
|
372
372
|
concat_merged_text("\n") unless opts[:in_tag] || opts[:nuke_inner_whitespace]
|
|
373
373
|
@newlines -= 1
|
|
374
374
|
return
|
|
@@ -378,7 +378,7 @@ END
|
|
|
378
378
|
|
|
379
379
|
push_silent "haml_temp = #{text}"
|
|
380
380
|
newline_now
|
|
381
|
-
push_and_tabulate([:loud, "_hamlout.buffer << #{no_format ? "
|
|
381
|
+
push_and_tabulate([:loud, "_hamlout.buffer << #{no_format ? "haml_temp.to_s;" : "#{static_method}(haml_temp);"}",
|
|
382
382
|
!(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])])
|
|
383
383
|
end
|
|
384
384
|
|
data/lib/haml/util.rb
CHANGED
|
@@ -122,6 +122,17 @@ module Haml
|
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
+
# Returns information about the caller of the previous method.
|
|
126
|
+
#
|
|
127
|
+
# @param entry [String] An entry in the `#caller` list, or a similarly formatted string
|
|
128
|
+
# @return [[String, Fixnum, (String, nil)]] An array containing the filename, line, and method name of the caller.
|
|
129
|
+
# The method name may be nil
|
|
130
|
+
def caller_info(entry = caller[1])
|
|
131
|
+
info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first
|
|
132
|
+
info[1] = info[1].to_i
|
|
133
|
+
info
|
|
134
|
+
end
|
|
135
|
+
|
|
125
136
|
## Rails XSS Safety
|
|
126
137
|
|
|
127
138
|
# Whether or not ActionView's XSS protection is available and enabled,
|
|
@@ -246,9 +257,10 @@ MSG
|
|
|
246
257
|
# @param erb [String] The template for the method code
|
|
247
258
|
def def_static_method(klass, name, args, *vars)
|
|
248
259
|
erb = vars.pop
|
|
260
|
+
info = caller_info
|
|
249
261
|
powerset(vars).each do |set|
|
|
250
262
|
context = StaticConditionalContext.new(set).instance_eval {binding}
|
|
251
|
-
klass.class_eval(<<METHOD)
|
|
263
|
+
klass.class_eval(<<METHOD, info[0], info[1])
|
|
252
264
|
def #{static_method_name(name, *vars.map {|v| set.include?(v)})}(#{args.join(', ')})
|
|
253
265
|
#{ERB.new(erb).result(context)}
|
|
254
266
|
end
|
|
@@ -181,7 +181,7 @@ module Sass::Script
|
|
|
181
181
|
# It yields a number to a block to perform the operation and return a number
|
|
182
182
|
def numeric_transformation(value)
|
|
183
183
|
unless value.is_a?(Sass::Script::Number)
|
|
184
|
-
calling_function =
|
|
184
|
+
calling_function = Haml::Util.caller_info[2]
|
|
185
185
|
raise Sass::SyntaxError.new("#{value} is not a number for `#{calling_function}'")
|
|
186
186
|
end
|
|
187
187
|
Sass::Script::Number.new(yield(value.value), value.numerator_units, value.denominator_units)
|
data/test/haml/helper_test.rb
CHANGED
|
@@ -240,7 +240,7 @@ MESSAGE
|
|
|
240
240
|
render("%p foo\n= haml_concat 'foo'\n%p bar")
|
|
241
241
|
assert false, "Expected Haml::Error"
|
|
242
242
|
rescue Haml::Error => e
|
|
243
|
-
assert_equal 2, e.backtrace[
|
|
243
|
+
assert_equal 2, e.backtrace[1].scan(/:(\d+)/).first.first.to_i
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
def test_error_return_line_in_helper
|
data/test/haml/util_test.rb
CHANGED
|
@@ -69,6 +69,14 @@ class UtilTest < Test::Unit::TestCase
|
|
|
69
69
|
enum_with_index(%w[foo bar baz]).map {|s, i| "#{s}#{i}"})
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def test_caller_info
|
|
73
|
+
assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'"))
|
|
74
|
+
assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12"))
|
|
75
|
+
assert_equal(["(haml)", 12, "blah"], caller_info("(haml):12: in `blah'"))
|
|
76
|
+
assert_equal(["", 12, "boop"], caller_info(":12: in `boop'"))
|
|
77
|
+
assert_equal(["/tmp/foo.rb", -12, "fizzle"], caller_info("/tmp/foo.rb:-12: in `fizzle'"))
|
|
78
|
+
end
|
|
79
|
+
|
|
72
80
|
def test_def_static_method
|
|
73
81
|
klass = Class.new
|
|
74
82
|
def_static_method(klass, :static_method, [:arg1, :arg2],
|
data/test/test_helper.rb
CHANGED
|
@@ -18,7 +18,7 @@ end
|
|
|
18
18
|
class Test::Unit::TestCase
|
|
19
19
|
def munge_filename(opts)
|
|
20
20
|
return if opts[:filename]
|
|
21
|
-
test_name = caller[1]
|
|
21
|
+
test_name = Haml::Util.caller_info(caller[1])[2]
|
|
22
22
|
opts[:filename] = "#{test_name}_inline.sass"
|
|
23
23
|
end
|
|
24
24
|
|
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: 2.3.
|
|
4
|
+
version: 2.3.59
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Weizenbaum
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2009-10-
|
|
13
|
+
date: 2009-10-25 00:00:00 -04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|