haml-edge 2.3.169 → 2.3.170
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/EDGE_GEM_VERSION +1 -1
- data/Rakefile +4 -3
- data/VERSION +1 -1
- data/extra/haml-mode.el +1 -1
- data/extra/sass-mode.el +2 -2
- data/lib/haml.rb +1 -0
- data/lib/haml/buffer.rb +14 -1
- data/lib/haml/exec.rb +4 -0
- data/lib/haml/filters.rb +8 -2
- data/lib/haml/helpers.rb +27 -0
- data/lib/haml/helpers/action_view_mods.rb +73 -34
- data/lib/haml/helpers/xss_mods.rb +18 -0
- data/lib/haml/html.rb +1 -1
- data/lib/haml/precompiler.rb +16 -2
- data/lib/haml/railtie.rb +14 -0
- data/lib/haml/template/plugin.rb +32 -0
- data/lib/haml/util.rb +33 -0
- data/lib/sass/tree/rule_node.rb +43 -14
- data/test/haml/engine_test.rb +79 -2
- data/test/haml/helper_test.rb +45 -7
- data/test/haml/results/just_stuff.xhtml +2 -0
- data/test/haml/template_test.rb +36 -8
- data/test/haml/templates/helpers.haml +13 -0
- data/test/haml/templates/just_stuff.haml +2 -0
- data/test/haml/templates/partial_layout.haml +6 -2
- data/test/haml/util_test.rb +5 -0
- data/test/sass/engine_test.rb +75 -0
- data/test/test_helper.rb +11 -1
- metadata +4 -3
data/.yardopts
CHANGED
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.170
|
data/Rakefile
CHANGED
@@ -90,7 +90,7 @@ end
|
|
90
90
|
task :release_elpa do
|
91
91
|
require 'tlsmail'
|
92
92
|
require 'time'
|
93
|
-
require 'haml'
|
93
|
+
require scope('lib/haml')
|
94
94
|
|
95
95
|
version = Haml.version[:number]
|
96
96
|
|
@@ -257,6 +257,7 @@ begin
|
|
257
257
|
files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
|
258
258
|
t.options << '--files' << files.join(',')
|
259
259
|
t.options << '--template-path' << scope('yard')
|
260
|
+
t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
|
260
261
|
end
|
261
262
|
Rake::Task['yard'].prerequisites.insert(0, 'yard:sass')
|
262
263
|
Rake::Task['yard'].instance_variable_set('@comment', nil)
|
@@ -367,12 +368,12 @@ namespace :test do
|
|
367
368
|
task :rails_compatibility do
|
368
369
|
`rm -rf test/rails`
|
369
370
|
puts "Checking out rails. Please wait."
|
370
|
-
system("git clone
|
371
|
+
system("git clone git://github.com/rails/rails.git test/rails") rescue nil
|
371
372
|
begin
|
372
373
|
rails_versions.each {|version| test_rails_version version}
|
373
374
|
|
374
375
|
puts "Checking out rails_xss. Please wait."
|
375
|
-
system("git clone
|
376
|
+
system("git clone git://github.com/NZKoz/rails_xss.git test/plugins/rails_xss")
|
376
377
|
test_rails_version(rails_versions.find {|s| s =~ /^v2\.3/})
|
377
378
|
ensure
|
378
379
|
`rm -rf test/rails`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.170
|
data/extra/haml-mode.el
CHANGED
data/extra/sass-mode.el
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
;; Author: Nathan Weizenbaum
|
6
6
|
;; URL: http://github.com/nex3/haml/tree/master
|
7
|
-
;; Version: 2.2.
|
7
|
+
;; Version: 2.2.21
|
8
8
|
;; Created: 2007-03-15
|
9
9
|
;; By: Nathan Weizenbaum
|
10
10
|
;; Keywords: markup, language, css
|
11
|
-
;; Package-Requires: ((haml-mode "2.2.
|
11
|
+
;; Package-Requires: ((haml-mode "2.2.21"))
|
12
12
|
|
13
13
|
;;; Commentary:
|
14
14
|
|
data/lib/haml.rb
CHANGED
data/lib/haml/buffer.rb
CHANGED
@@ -233,10 +233,11 @@ RUBY
|
|
233
233
|
|
234
234
|
# Merges two attribute hashes.
|
235
235
|
# This is the same as `to.merge!(from)`,
|
236
|
-
# except that it merges id and
|
236
|
+
# except that it merges id, class, and data attributes.
|
237
237
|
#
|
238
238
|
# ids are concatenated with `"_"`,
|
239
239
|
# and classes are concatenated with `" "`.
|
240
|
+
# data hashes are simply merged.
|
240
241
|
#
|
241
242
|
# Destructively modifies both `to` and `from`.
|
242
243
|
#
|
@@ -244,12 +245,14 @@ RUBY
|
|
244
245
|
# @param from [{String => #to_s}] The attribute hash to merge from
|
245
246
|
# @return [{String => String}] `to`, after being merged
|
246
247
|
def self.merge_attrs(to, from)
|
248
|
+
from['id'] = Precompiler.filter_and_join(from['id'], '_') if from['id']
|
247
249
|
if to['id'] && from['id']
|
248
250
|
to['id'] << '_' << from.delete('id').to_s
|
249
251
|
elsif to['id'] || from['id']
|
250
252
|
from['id'] ||= to['id']
|
251
253
|
end
|
252
254
|
|
255
|
+
from['class'] = Precompiler.filter_and_join(from['class'], ' ') if from['class']
|
253
256
|
if to['class'] && from['class']
|
254
257
|
# Make sure we don't duplicate class names
|
255
258
|
from['class'] = (from['class'].to_s.split(' ') | to['class'].split(' ')).sort.join(' ')
|
@@ -257,6 +260,16 @@ RUBY
|
|
257
260
|
from['class'] ||= to['class']
|
258
261
|
end
|
259
262
|
|
263
|
+
from_data = from['data'].is_a?(Hash)
|
264
|
+
to_data = to['data'].is_a?(Hash)
|
265
|
+
if from_data && to_data
|
266
|
+
to['data'] = to['data'].merge(from['data'])
|
267
|
+
elsif to_data
|
268
|
+
to = Haml::Util.map_keys(to.delete('data')) {|name| "data-#{name}"}.merge(to)
|
269
|
+
elsif from_data
|
270
|
+
from = Haml::Util.map_keys(from.delete('data')) {|name| "data-#{name}"}.merge(from)
|
271
|
+
end
|
272
|
+
|
260
273
|
to.merge!(from)
|
261
274
|
end
|
262
275
|
|
data/lib/haml/exec.rb
CHANGED
@@ -232,6 +232,10 @@ END
|
|
232
232
|
'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
|
233
233
|
@options[:for_engine][:style] = name.to_sym
|
234
234
|
end
|
235
|
+
opts.on('-g', '--debug-info',
|
236
|
+
'Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.') do
|
237
|
+
@options[:for_engine][:debug_info] = true
|
238
|
+
end
|
235
239
|
opts.on('-l', '--line-numbers', '--line-comments',
|
236
240
|
'Emit comments in the generated CSS indicating the corresponding sass line.') do
|
237
241
|
@options[:for_engine][:line_numbers] = true
|
data/lib/haml/filters.rb
CHANGED
@@ -100,8 +100,10 @@ module Haml
|
|
100
100
|
if contains_interpolation?(text)
|
101
101
|
return if options[:suppress_eval]
|
102
102
|
|
103
|
-
|
104
|
-
|
103
|
+
text = unescape_interpolation(text).gsub("\\n", "\n")
|
104
|
+
newline if text.gsub!(/\n"\Z/, "\\n\"")
|
105
|
+
push_script <<RUBY.strip, :escape_html => false
|
106
|
+
find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options))
|
105
107
|
RUBY
|
106
108
|
return
|
107
109
|
end
|
@@ -113,6 +115,10 @@ RUBY
|
|
113
115
|
else
|
114
116
|
push_text(rendered.rstrip)
|
115
117
|
end
|
118
|
+
|
119
|
+
(text.count("\n") - 1).times {newline}
|
120
|
+
resolve_newlines
|
121
|
+
newline
|
116
122
|
end
|
117
123
|
end
|
118
124
|
|
data/lib/haml/helpers.rb
CHANGED
@@ -234,6 +234,33 @@ MESSAGE
|
|
234
234
|
haml_buffer.tabulation -= i
|
235
235
|
end
|
236
236
|
|
237
|
+
# Sets the number of tabs the buffer automatically adds
|
238
|
+
# to the lines of the template,
|
239
|
+
# but only for the duration of the block.
|
240
|
+
# For example:
|
241
|
+
#
|
242
|
+
# %h1 foo
|
243
|
+
# - with_tabs(2) do
|
244
|
+
# %p bar
|
245
|
+
# %strong baz
|
246
|
+
#
|
247
|
+
# Produces:
|
248
|
+
#
|
249
|
+
# <h1>foo</h1>
|
250
|
+
# <p>bar</p>
|
251
|
+
# <strong>baz</strong>
|
252
|
+
#
|
253
|
+
#
|
254
|
+
# @param i [Fixnum] The number of tabs to use
|
255
|
+
# @yield A block in which the indentation will be `i` spaces
|
256
|
+
def with_tabs(i)
|
257
|
+
old_tabs = haml_buffer.tabulation
|
258
|
+
haml_buffer.tabulation = i
|
259
|
+
yield
|
260
|
+
ensure
|
261
|
+
haml_buffer.tabulation = old_tabs
|
262
|
+
end
|
263
|
+
|
237
264
|
# Surrounds a block of Haml code with strings,
|
238
265
|
# with no whitespace in between.
|
239
266
|
# For example:
|
@@ -131,52 +131,91 @@ module ActionView
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
if
|
134
|
+
if Haml::Util.ap_geq_3?
|
135
|
+
module FormTagHelper
|
136
|
+
def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
|
137
|
+
if is_haml?
|
138
|
+
if block_given?
|
139
|
+
oldproc = proc
|
140
|
+
proc = haml_bind_proc do |*args|
|
141
|
+
concat "\n"
|
142
|
+
with_tabs(1) {oldproc.call(*args)}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
|
146
|
+
res << "\n" if block_given?
|
147
|
+
res
|
148
|
+
else
|
149
|
+
form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
alias_method :form_tag_without_haml, :form_tag
|
153
|
+
alias_method :form_tag, :form_tag_with_haml
|
154
|
+
end
|
155
|
+
|
156
|
+
module FormHelper
|
157
|
+
def form_for_with_haml(object_name, *args, &proc)
|
158
|
+
if block_given? && is_haml?
|
138
159
|
oldproc = proc
|
139
160
|
proc = haml_bind_proc do |*args|
|
140
|
-
|
141
|
-
tab_up
|
142
|
-
oldproc.call(*args)
|
143
|
-
tab_down
|
144
|
-
concat haml_indent
|
161
|
+
with_tabs(1) {oldproc.call(*args)}
|
145
162
|
end
|
146
|
-
concat haml_indent
|
147
|
-
end
|
148
|
-
res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
|
149
|
-
if block_given?
|
150
|
-
concat "\n"
|
151
|
-
return Haml::Helpers::ErrorReturn.new("form_tag")
|
152
163
|
end
|
164
|
+
res = form_for_without_haml(object_name, *args, &proc)
|
165
|
+
res << "\n" if block_given? && is_haml?
|
153
166
|
res
|
154
|
-
else
|
155
|
-
form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
|
156
167
|
end
|
168
|
+
alias_method :form_for_without_haml, :form_for
|
169
|
+
alias_method :form_for, :form_for_with_haml
|
170
|
+
end
|
171
|
+
else
|
172
|
+
module FormTagHelper
|
173
|
+
def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
|
174
|
+
if is_haml?
|
175
|
+
if block_given?
|
176
|
+
oldproc = proc
|
177
|
+
proc = haml_bind_proc do |*args|
|
178
|
+
concat "\n"
|
179
|
+
tab_up
|
180
|
+
oldproc.call(*args)
|
181
|
+
tab_down
|
182
|
+
concat haml_indent
|
183
|
+
end
|
184
|
+
concat haml_indent
|
185
|
+
end
|
186
|
+
res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
|
187
|
+
if block_given?
|
188
|
+
concat "\n"
|
189
|
+
return Haml::Helpers::ErrorReturn.new("form_tag")
|
190
|
+
end
|
191
|
+
res
|
192
|
+
else
|
193
|
+
form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
alias_method :form_tag_without_haml, :form_tag
|
197
|
+
alias_method :form_tag, :form_tag_with_haml
|
157
198
|
end
|
158
|
-
alias_method :form_tag_without_haml, :form_tag
|
159
|
-
alias_method :form_tag, :form_tag_with_haml
|
160
|
-
end
|
161
199
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
200
|
+
module FormHelper
|
201
|
+
def form_for_with_haml(object_name, *args, &proc)
|
202
|
+
if block_given? && is_haml?
|
203
|
+
oldproc = proc
|
204
|
+
proc = haml_bind_proc do |*args|
|
205
|
+
tab_up
|
206
|
+
oldproc.call(*args)
|
207
|
+
tab_down
|
208
|
+
concat haml_indent
|
209
|
+
end
|
170
210
|
concat haml_indent
|
171
211
|
end
|
172
|
-
|
212
|
+
form_for_without_haml(object_name, *args, &proc)
|
213
|
+
concat "\n" if block_given? && is_haml?
|
214
|
+
Haml::Helpers::ErrorReturn.new("form_for") if is_haml?
|
173
215
|
end
|
174
|
-
form_for_without_haml
|
175
|
-
|
176
|
-
Haml::Helpers::ErrorReturn.new("form_for") if is_haml?
|
216
|
+
alias_method :form_for_without_haml, :form_for
|
217
|
+
alias_method :form_for, :form_for_with_haml
|
177
218
|
end
|
178
|
-
alias_method :form_for_without_haml, :form_for
|
179
|
-
alias_method :form_for, :form_for_with_haml
|
180
219
|
end
|
181
220
|
end
|
182
221
|
end
|
@@ -104,6 +104,14 @@ end
|
|
104
104
|
|
105
105
|
module ActionView
|
106
106
|
module Helpers
|
107
|
+
module CaptureHelper
|
108
|
+
def with_output_buffer_with_haml_xss(*args, &block)
|
109
|
+
Haml::Util.html_safe(with_output_buffer_without_haml_xss(*args, &block))
|
110
|
+
end
|
111
|
+
alias_method :with_output_buffer_without_haml_xss, :with_output_buffer
|
112
|
+
alias_method :with_output_buffer, :with_output_buffer_with_haml_xss
|
113
|
+
end
|
114
|
+
|
107
115
|
module FormTagHelper
|
108
116
|
def form_tag_with_haml_xss(*args, &block)
|
109
117
|
res = form_tag_without_haml_xss(*args, &block)
|
@@ -114,6 +122,16 @@ module ActionView
|
|
114
122
|
alias_method :form_tag, :form_tag_with_haml_xss
|
115
123
|
end
|
116
124
|
|
125
|
+
module FormHelper
|
126
|
+
def form_for_with_haml_xss(*args, &block)
|
127
|
+
res = form_for_without_haml_xss(*args, &block)
|
128
|
+
return Haml::Util.html_safe(res) if res.is_a?(String)
|
129
|
+
return res
|
130
|
+
end
|
131
|
+
alias_method :form_for_without_haml_xss, :form_for
|
132
|
+
alias_method :form_for, :form_for_with_haml_xss
|
133
|
+
end
|
134
|
+
|
117
135
|
module TextHelper
|
118
136
|
def concat_with_haml_xss(string)
|
119
137
|
if is_haml?
|
data/lib/haml/html.rb
CHANGED
@@ -109,7 +109,7 @@ module Haml
|
|
109
109
|
#
|
110
110
|
# Example usage:
|
111
111
|
#
|
112
|
-
# Haml::
|
112
|
+
# Haml::HTML.new("<a href='http://google.com'>Blat</a>").render
|
113
113
|
# #=> "%a{:href => 'http://google.com'} Blat"
|
114
114
|
class HTML
|
115
115
|
# @param template [String, Hpricot::Node] The HTML template to convert
|
data/lib/haml/precompiler.rb
CHANGED
@@ -189,7 +189,6 @@ END
|
|
189
189
|
if flat?
|
190
190
|
push_flat(@line)
|
191
191
|
@line = @next_line
|
192
|
-
newline
|
193
192
|
next
|
194
193
|
end
|
195
194
|
|
@@ -245,11 +244,12 @@ END
|
|
245
244
|
return start_haml_comment if text[1] == SILENT_COMMENT
|
246
245
|
|
247
246
|
raise SyntaxError.new(<<END.rstrip, index) if text[1..-1].strip == "end"
|
248
|
-
You don't need to use "- end" in Haml.
|
247
|
+
You don't need to use "- end" in Haml. Un-indent to close a block:
|
249
248
|
- if foo?
|
250
249
|
%strong Foo!
|
251
250
|
- else
|
252
251
|
Not foo.
|
252
|
+
%p This line is un-indented, so it isn't part of the "if" block
|
253
253
|
END
|
254
254
|
|
255
255
|
push_silent(text[1..-1], true)
|
@@ -541,9 +541,18 @@ END
|
|
541
541
|
quote_escape = attr_wrapper == '"' ? """ : "'"
|
542
542
|
other_quote_char = attr_wrapper == '"' ? "'" : '"'
|
543
543
|
|
544
|
+
if attributes['data'].is_a?(Hash)
|
545
|
+
attributes = attributes.dup
|
546
|
+
attributes =
|
547
|
+
Haml::Util.map_keys(attributes.delete('data')) {|name| "data-#{name}"}.merge(attributes)
|
548
|
+
end
|
549
|
+
|
544
550
|
result = attributes.collect do |attr, value|
|
545
551
|
next if value.nil?
|
546
552
|
|
553
|
+
value = filter_and_join(value, ' ') if attr == :class
|
554
|
+
value = filter_and_join(value, '_') if attr == :id
|
555
|
+
|
547
556
|
if value == true
|
548
557
|
next " #{attr}" if is_html
|
549
558
|
next " #{attr}=#{attr_wrapper}#{attr}#{attr_wrapper}"
|
@@ -567,6 +576,11 @@ END
|
|
567
576
|
result.compact.sort.join
|
568
577
|
end
|
569
578
|
|
579
|
+
def self.filter_and_join(value, separator)
|
580
|
+
value = [value] unless value.is_a?(Array)
|
581
|
+
return value.flatten.collect {|item| item ? item.to_s : nil}.compact.join(separator)
|
582
|
+
end
|
583
|
+
|
570
584
|
def prerender_tag(name, self_close, attributes)
|
571
585
|
attributes_string = Precompiler.build_attributes(html?, @options[:attr_wrapper], attributes)
|
572
586
|
"<#{name}#{attributes_string}#{self_close && xhtml? ? ' /' : ''}>"
|
data/lib/haml/railtie.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file is here to integrate with Rails 3,
|
2
|
+
# since there's no better way to do so as of 14 March 2010.
|
3
|
+
# Yehuda promises there will be soon,
|
4
|
+
# and once there is we should switch to that.
|
5
|
+
|
6
|
+
if defined?(Rails::Railtie)
|
7
|
+
module Haml
|
8
|
+
class Railtie < Rails::Railtie
|
9
|
+
initializer :haml do
|
10
|
+
Haml.init_rails(binding)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/haml/template/plugin.rb
CHANGED
@@ -33,6 +33,38 @@ module Haml
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
# Rails 3.0 prints a deprecation warning when block helpers
|
38
|
+
# return strings that go unused.
|
39
|
+
# We want to print the same deprecation warning,
|
40
|
+
# so we have to compile in a method call to check for it.
|
41
|
+
#
|
42
|
+
# I don't like having this in the precompiler pipeline,
|
43
|
+
# and I'd like to get rid of it once Rails 3.1 is well-established.
|
44
|
+
if defined?(ActionView::OutputBuffer) &&
|
45
|
+
Haml::Util.has?(:instance_method, ActionView::OutputBuffer, :append_if_string=)
|
46
|
+
module Precompiler
|
47
|
+
def push_silent_with_haml_block_deprecation(text, can_suppress = false)
|
48
|
+
unless can_suppress && block_opened? && !mid_block_keyword?("- #{text}") &&
|
49
|
+
text =~ ActionView::Template::Handlers::Erubis::BLOCK_EXPR
|
50
|
+
return push_silent_without_haml_block_deprecation(text, can_suppress)
|
51
|
+
end
|
52
|
+
|
53
|
+
push_silent_without_haml_block_deprecation("_hamlout.append_if_string= #{text}", can_suppress)
|
54
|
+
end
|
55
|
+
alias_method :push_silent_without_haml_block_deprecation, :push_silent
|
56
|
+
alias_method :push_silent, :push_silent_with_haml_block_deprecation
|
57
|
+
end
|
58
|
+
|
59
|
+
class Buffer
|
60
|
+
def append_if_string=(value)
|
61
|
+
if value.is_a?(String) && !value.is_a?(ActionView::NonConcattingString)
|
62
|
+
ActiveSupport::Deprecation.warn("- style block helpers are deprecated. Please use =", caller)
|
63
|
+
buffer << value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
36
68
|
end
|
37
69
|
|
38
70
|
if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
|
data/lib/haml/util.rb
CHANGED
@@ -179,6 +179,31 @@ module Haml
|
|
179
179
|
return nil
|
180
180
|
end
|
181
181
|
|
182
|
+
# Returns whether this environment is using ActionPack
|
183
|
+
# version 3.0.0 or greater.
|
184
|
+
#
|
185
|
+
# @return [Boolean]
|
186
|
+
def ap_geq_3?
|
187
|
+
# The ActionPack module is always loaded automatically in Rails >= 3
|
188
|
+
return false unless defined?(ActionPack) && defined?(ActionPack::VERSION)
|
189
|
+
|
190
|
+
version =
|
191
|
+
if defined?(ActionPack::VERSION::MAJOR)
|
192
|
+
ActionPack::VERSION::MAJOR
|
193
|
+
else
|
194
|
+
# Rails 1.2
|
195
|
+
ActionPack::VERSION::Major
|
196
|
+
end
|
197
|
+
|
198
|
+
# 3.0.0.beta1 acts more like ActionPack 2
|
199
|
+
# for purposes of this method
|
200
|
+
# (checking whether block helpers require = or -).
|
201
|
+
# This extra check can be removed when beta2 is out.
|
202
|
+
version >= 3 &&
|
203
|
+
!(defined?(ActionPack::VERSION::TINY) &&
|
204
|
+
ActionPack::VERSION::TINY == "0.beta")
|
205
|
+
end
|
206
|
+
|
182
207
|
# Returns an ActionView::Template* class.
|
183
208
|
# In pre-3.0 versions of Rails, most of these classes
|
184
209
|
# were of the form `ActionView::TemplateFoo`,
|
@@ -299,6 +324,14 @@ MSG
|
|
299
324
|
ruby1_8? ? enum.enum_with_index : enum.each_with_index
|
300
325
|
end
|
301
326
|
|
327
|
+
# Returns the ASCII code of the given character.
|
328
|
+
#
|
329
|
+
# @param c [String] All characters but the first are ignored.
|
330
|
+
# @return [Fixnum] The ASCII code of `c`.
|
331
|
+
def ord(c)
|
332
|
+
ruby1_8? ? c[0] : c.ord
|
333
|
+
end
|
334
|
+
|
302
335
|
## Static Method Stuff
|
303
336
|
|
304
337
|
# The context in which the ERB for \{#def\_static\_method} will be run.
|
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -132,23 +132,27 @@ module Sass::Tree
|
|
132
132
|
to_return = ''
|
133
133
|
old_spaces = ' ' * (tabs - 1)
|
134
134
|
spaces = ' ' * tabs
|
135
|
-
if
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
135
|
+
if style != :compressed
|
136
|
+
if @options[:debug_info]
|
137
|
+
to_return << debug_info_rule.to_s(tabs) << "\n"
|
138
|
+
elsif @options[:line_comments]
|
139
|
+
to_return << "#{old_spaces}/* line #{line}"
|
140
|
+
|
141
|
+
if filename
|
142
|
+
relative_filename = if @options[:css_filename]
|
143
|
+
begin
|
144
|
+
Pathname.new(filename).relative_path_from(
|
145
|
+
Pathname.new(File.dirname(@options[:css_filename]))).to_s
|
146
|
+
rescue ArgumentError
|
147
|
+
nil
|
148
|
+
end
|
145
149
|
end
|
150
|
+
relative_filename ||= filename
|
151
|
+
to_return << ", #{relative_filename}"
|
146
152
|
end
|
147
|
-
relative_filename ||= filename
|
148
|
-
to_return << ", #{relative_filename}"
|
149
|
-
end
|
150
153
|
|
151
|
-
|
154
|
+
to_return << " */\n"
|
155
|
+
end
|
152
156
|
end
|
153
157
|
|
154
158
|
if style == :compact
|
@@ -207,6 +211,16 @@ module Sass::Tree
|
|
207
211
|
super
|
208
212
|
end
|
209
213
|
|
214
|
+
# A hash that will be associated with this rule in the CSS document
|
215
|
+
# if the {file:SASS_REFERENCE.md#debug_info-option `:debug_info` option} is enabled.
|
216
|
+
# This data is used by e.g. [the FireSass Firebug extension](https://addons.mozilla.org/en-US/firefox/addon/103988).
|
217
|
+
#
|
218
|
+
# @return [{#to_s => #to_s}]
|
219
|
+
def debug_info
|
220
|
+
{:filename => filename && ("file://" + URI.escape(File.expand_path(filename))),
|
221
|
+
:line => self.line}
|
222
|
+
end
|
223
|
+
|
210
224
|
private
|
211
225
|
|
212
226
|
def resolve_parent_refs(super_rules)
|
@@ -267,5 +281,20 @@ module Sass::Tree
|
|
267
281
|
|
268
282
|
rules
|
269
283
|
end
|
284
|
+
|
285
|
+
def debug_info_rule
|
286
|
+
node = DirectiveNode.new("@media -sass-debug-info")
|
287
|
+
debug_info.each do |k, v|
|
288
|
+
rule = RuleNode.new(nil)
|
289
|
+
rule.resolved_rules = [[k.to_s.gsub(/[^\w-]/, "\\\\\\0")]]
|
290
|
+
val = v.to_s.gsub(/[^\w-]/, "\\\\\\0").
|
291
|
+
gsub(/^[\d-]/) {|c| "\\%04x " % Haml::Util.ord(c)}
|
292
|
+
prop = PropNode.new("font-family", val, :new)
|
293
|
+
rule << prop
|
294
|
+
node << rule
|
295
|
+
end
|
296
|
+
node.options = @options.merge(:debug_info => false, :line_comments => false, :style => :compressed)
|
297
|
+
node
|
298
|
+
end
|
270
299
|
end
|
271
300
|
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -36,7 +36,14 @@ class EngineTest < Test::Unit::TestCase
|
|
36
36
|
"%p{:a => 'b',\n:c => 'd',\n:e => raise('foo')}" => ["foo", 3],
|
37
37
|
" %p foo" => "Indenting at the beginning of the document is illegal.",
|
38
38
|
" %p foo" => "Indenting at the beginning of the document is illegal.",
|
39
|
-
"- end" =>
|
39
|
+
"- end" => <<MESSAGE.rstrip,
|
40
|
+
You don't need to use "- end" in Haml. Un-indent to close a block:
|
41
|
+
- if foo?
|
42
|
+
%strong Foo!
|
43
|
+
- else
|
44
|
+
Not foo.
|
45
|
+
%p This line is un-indented, so it isn't part of the "if" block
|
46
|
+
MESSAGE
|
40
47
|
" \n\t\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
|
41
48
|
"\n\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
|
42
49
|
"%p\n foo\n foo" => ["Inconsistent indentation: 1 space was used for indentation, but the rest of the document was indented using 2 spaces.", 3],
|
@@ -73,6 +80,11 @@ class EngineTest < Test::Unit::TestCase
|
|
73
80
|
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
|
74
81
|
"foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
75
82
|
"foo\n:erb\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
83
|
+
"foo\n:plain\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
84
|
+
"foo\n:plain\n 1\n 2\n 3\n4\n- raise 'foo'" => ["foo", 7],
|
85
|
+
"foo\n:plain\n 1\n 2\n 3\#{''}\n- raise 'foo'" => ["foo", 6],
|
86
|
+
"foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7],
|
87
|
+
"foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5],
|
76
88
|
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
77
89
|
}
|
78
90
|
|
@@ -130,6 +142,29 @@ class EngineTest < Test::Unit::TestCase
|
|
130
142
|
assert_equal("<p class='3'>foo</p>", render("%p{:class => 1+2} foo").chomp)
|
131
143
|
end
|
132
144
|
|
145
|
+
def test_class_attr_with_array
|
146
|
+
assert_equal("<p class='a b'>foo</p>\n", render("%p{:class => %w[a b]} foo")) # basic
|
147
|
+
assert_equal("<p class='a b css'>foo</p>\n", render("%p.css{:class => %w[a b]} foo")) # merge with css
|
148
|
+
assert_equal("<p class='b css'>foo</p>\n", render("%p.css{:class => %w[css b]} foo")) # merge uniquely
|
149
|
+
assert_equal("<p class='a b c d'>foo</p>\n", render("%p{:class => [%w[a b], %w[c d]]} foo")) # flatten
|
150
|
+
assert_equal("<p class='a b'>foo</p>\n", render("%p{:class => [:a, :b] } foo")) # stringify
|
151
|
+
assert_equal("<p class=''>foo</p>\n", render("%p{:class => [nil, false] } foo")) # strip falsey
|
152
|
+
assert_equal("<p class='a'>foo</p>\n", render("%p{:class => :a} foo")) # single stringify
|
153
|
+
assert_equal("<p>foo</p>\n", render("%p{:class => false} foo")) # single falsey
|
154
|
+
assert_equal("<p class='a b html'>foo</p>\n", render("%p(class='html'){:class => %w[a b]} foo")) # html attrs
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_id_attr_with_array
|
158
|
+
assert_equal("<p id='a_b'>foo</p>\n", render("%p{:id => %w[a b]} foo")) # basic
|
159
|
+
assert_equal("<p id='css_a_b'>foo</p>\n", render("%p#css{:id => %w[a b]} foo")) # merge with css
|
160
|
+
assert_equal("<p id='a_b_c_d'>foo</p>\n", render("%p{:id => [%w[a b], %w[c d]]} foo")) # flatten
|
161
|
+
assert_equal("<p id='a_b'>foo</p>\n", render("%p{:id => [:a, :b] } foo")) # stringify
|
162
|
+
assert_equal("<p id=''>foo</p>\n", render("%p{:id => [nil, false] } foo")) # strip falsey
|
163
|
+
assert_equal("<p id='a'>foo</p>\n", render("%p{:id => :a} foo")) # single stringify
|
164
|
+
assert_equal("<p>foo</p>\n", render("%p{:id => false} foo")) # single falsey
|
165
|
+
assert_equal("<p id='html_a_b'>foo</p>\n", render("%p(id='html'){:id => %w[a b]} foo")) # html attrs
|
166
|
+
end
|
167
|
+
|
133
168
|
def test_dynamic_attributes_with_no_content
|
134
169
|
assert_equal(<<HTML, render(<<HAML))
|
135
170
|
<p>
|
@@ -611,8 +646,9 @@ HAML
|
|
611
646
|
<p>foo-end</p>
|
612
647
|
<p>bar-end</p>
|
613
648
|
HTML
|
614
|
-
- "foo-end-bar-end".gsub(/\\w+-end/) do |s|
|
649
|
+
- ("foo-end-bar-end".gsub(/\\w+-end/) do |s|
|
615
650
|
%p= s
|
651
|
+
- end; nil)
|
616
652
|
HAML
|
617
653
|
end
|
618
654
|
|
@@ -1164,6 +1200,47 @@ SASS
|
|
1164
1200
|
assert_equal %{<!DOCTYPE html>\n}, render('!!!', :format => :html5)
|
1165
1201
|
end
|
1166
1202
|
|
1203
|
+
# HTML5 custom data attributes
|
1204
|
+
def test_html5_data_attributes
|
1205
|
+
assert_equal("<div data-author_id='123' data-biz='baz' data-foo='bar'></div>\n",
|
1206
|
+
render("%div{:data => {:author_id => 123, :foo => 'bar', :biz => 'baz'}}"))
|
1207
|
+
|
1208
|
+
assert_equal("<div data-one_plus_one='2'></div>\n",
|
1209
|
+
render("%div{:data => {:one_plus_one => 1+1}}"))
|
1210
|
+
|
1211
|
+
assert_equal("<div data-foo='Here's a \"quoteful\" string.'></div>\n",
|
1212
|
+
render(%{%div{:data => {:foo => %{Here's a "quoteful" string.}}}})) #'
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
def test_html5_data_attributes_with_multiple_defs
|
1216
|
+
# Should always use the more-explicit attribute
|
1217
|
+
assert_equal("<div data-foo='second'></div>\n",
|
1218
|
+
render("%div{:data => {:foo => 'first'}, 'data-foo' => 'second'}"))
|
1219
|
+
assert_equal("<div data-foo='first'></div>\n",
|
1220
|
+
render("%div{'data-foo' => 'first', :data => {:foo => 'second'}}"))
|
1221
|
+
end
|
1222
|
+
|
1223
|
+
def test_html5_data_attributes_with_attr_method
|
1224
|
+
Haml::Helpers.module_eval do
|
1225
|
+
def data_hash
|
1226
|
+
{:data => {:foo => "bar", :baz => "bang"}}
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
def data_val
|
1230
|
+
{:data => "dat"}
|
1231
|
+
end
|
1232
|
+
end
|
1233
|
+
|
1234
|
+
assert_equal("<div data-baz='bang' data-brat='wurst' data-foo='blip'></div>\n",
|
1235
|
+
render("%div{data_hash, :data => {:foo => 'blip', :brat => 'wurst'}}"))
|
1236
|
+
assert_equal("<div data-baz='bang' data-foo='blip'></div>\n",
|
1237
|
+
render("%div{data_hash, 'data-foo' => 'blip'}"))
|
1238
|
+
assert_equal("<div data-baz='bang' data-foo='bar' data='dat'></div>\n",
|
1239
|
+
render("%div{data_hash, :data => 'dat'}"))
|
1240
|
+
assert_equal("<div data-brat='wurst' data-foo='blip' data='dat'></div>\n",
|
1241
|
+
render("%div{data_val, :data => {:foo => 'blip', :brat => 'wurst'}}"))
|
1242
|
+
end
|
1243
|
+
|
1167
1244
|
# New attributes
|
1168
1245
|
|
1169
1246
|
def test_basic_new_attributes
|
data/test/haml/helper_test.rb
CHANGED
@@ -65,7 +65,21 @@ class HelperTest < Test::Unit::TestCase
|
|
65
65
|
assert_equal("foo\n bar\nbaz\n", render("foo\n- tab_up\nbar\n- tab_down\nbaz"))
|
66
66
|
assert_equal(" <p>tabbed</p>\n", render("- buffer.tabulation=5\n%p tabbed"))
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
|
+
def test_with_tabs
|
70
|
+
assert_equal(<<HTML, render(<<HAML))
|
71
|
+
Foo
|
72
|
+
Bar
|
73
|
+
Baz
|
74
|
+
Baz
|
75
|
+
HTML
|
76
|
+
Foo
|
77
|
+
- with_tabs 2 do
|
78
|
+
= "Bar\\nBaz"
|
79
|
+
Baz
|
80
|
+
HAML
|
81
|
+
end
|
82
|
+
|
69
83
|
def test_helpers_dont_leak
|
70
84
|
# Haml helpers shouldn't be accessible from ERB
|
71
85
|
render("foo")
|
@@ -93,9 +107,16 @@ class HelperTest < Test::Unit::TestCase
|
|
93
107
|
def test_form_tag
|
94
108
|
# This is usually provided by ActionController::Base.
|
95
109
|
def @base.protect_against_forgery?; false; end
|
96
|
-
|
97
|
-
|
98
|
-
|
110
|
+
assert_equal(<<HTML, render(<<HAML, :action_view))
|
111
|
+
<form action="foo" method="post">
|
112
|
+
<p>bar</p>
|
113
|
+
<strong>baz</strong>
|
114
|
+
</form>
|
115
|
+
HTML
|
116
|
+
#{rails_block_helper_char} form_tag 'foo' do
|
117
|
+
%p bar
|
118
|
+
%strong baz
|
119
|
+
HAML
|
99
120
|
end
|
100
121
|
|
101
122
|
def test_text_area
|
@@ -110,16 +131,23 @@ class HelperTest < Test::Unit::TestCase
|
|
110
131
|
end
|
111
132
|
|
112
133
|
def test_capture_haml
|
113
|
-
assert_equal(
|
134
|
+
assert_equal(<<HTML, render(<<HAML))
|
135
|
+
"<p>13</p>\\n"
|
136
|
+
HTML
|
137
|
+
- (foo = capture_haml(13) do |a|
|
138
|
+
%p= a
|
139
|
+
- end; nil)
|
140
|
+
= foo.dump
|
141
|
+
HAML
|
114
142
|
end
|
115
143
|
|
116
144
|
def test_content_tag_block
|
117
|
-
assert_equal(<<HTML.strip, render(<<HAML, :action_view))
|
145
|
+
assert_equal(<<HTML.strip, render(<<HAML, :action_view).strip)
|
118
146
|
<div><p>bar</p>
|
119
147
|
<strong>bar</strong>
|
120
148
|
</div>
|
121
149
|
HTML
|
122
|
-
|
150
|
+
#{rails_block_helper_char} content_tag :div do
|
123
151
|
%p bar
|
124
152
|
%strong bar
|
125
153
|
HAML
|
@@ -177,6 +205,16 @@ HAML
|
|
177
205
|
assert_equal("<br class='foo' />\n", render("- haml_tag :br, :class => 'foo'"))
|
178
206
|
end
|
179
207
|
|
208
|
+
def test_haml_tag_with_class_array
|
209
|
+
assert_equal("<p class='a b'>foo</p>\n", render("- haml_tag :p, 'foo', :class => %w[a b]"))
|
210
|
+
assert_equal("<p class='a b c d'>foo</p>\n", render("- haml_tag 'p.c.d', 'foo', :class => %w[a b]"))
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_haml_tag_with_id_array
|
214
|
+
assert_equal("<p id='a_b'>foo</p>\n", render("- haml_tag :p, 'foo', :id => %w[a b]"))
|
215
|
+
assert_equal("<p id='c_a_b'>foo</p>\n", render("- haml_tag 'p#c', 'foo', :id => %w[a b]"))
|
216
|
+
end
|
217
|
+
|
180
218
|
def test_haml_tag_non_autoclosed_tags_arent_closed
|
181
219
|
assert_equal("<p></p>\n", render("- haml_tag :p"))
|
182
220
|
end
|
@@ -56,7 +56,9 @@ testtest
|
|
56
56
|
</br>
|
57
57
|
<p class='article bar foo' id='article_1'>Blah</p>
|
58
58
|
<p class='article foo' id='article_1'>Blah</p>
|
59
|
+
<p class='article bar baz foo' id='article_1'>Blah</p>
|
59
60
|
<p class='article quux qux' id='article_1'>Blump</p>
|
61
|
+
<p class='article' id='foo_bar_baz_article_1'>Whee</p>
|
60
62
|
Woah inner quotes
|
61
63
|
<p class='dynamic_quote' dyn='3' quotes="single '"></p>
|
62
64
|
<p class='dynamic_self_closing' dyn='3' />
|
data/test/haml/template_test.rb
CHANGED
@@ -70,8 +70,9 @@ class TemplateTest < Test::Unit::TestCase
|
|
70
70
|
end
|
71
71
|
|
72
72
|
if Haml::Util.has?(:private_method, base, :evaluate_assigns)
|
73
|
+
# Rails < 3.0
|
73
74
|
base.send(:evaluate_assigns)
|
74
|
-
|
75
|
+
elsif Haml::Util.has?(:private_method, base, :_evaluate_assigns_and_ivars)
|
75
76
|
# Rails 2.2
|
76
77
|
base.send(:_evaluate_assigns_and_ivars)
|
77
78
|
end
|
@@ -190,22 +191,24 @@ class TemplateTest < Test::Unit::TestCase
|
|
190
191
|
assert_equal("2\n", render("= 1+1"))
|
191
192
|
end
|
192
193
|
|
193
|
-
|
194
|
-
|
194
|
+
unless Haml::Util.ap_geq_3?
|
195
|
+
def test_form_for_error_return
|
196
|
+
assert_raise(Haml::Error) { render(<<HAML) }
|
195
197
|
= form_for :article, @article, :url => '' do |f|
|
196
198
|
Title:
|
197
199
|
= f.text_field :title
|
198
200
|
Body:
|
199
201
|
= f.text_field :body
|
200
202
|
HAML
|
201
|
-
|
203
|
+
end
|
202
204
|
|
203
|
-
|
204
|
-
|
205
|
+
def test_form_tag_error_return
|
206
|
+
assert_raise(Haml::Error) { render(<<HAML) }
|
205
207
|
= form_tag '' do
|
206
208
|
Title:
|
207
209
|
Body:
|
208
210
|
HAML
|
211
|
+
end
|
209
212
|
end
|
210
213
|
|
211
214
|
def test_haml_options
|
@@ -228,10 +231,13 @@ baz
|
|
228
231
|
HTML
|
229
232
|
%p
|
230
233
|
foo
|
231
|
-
|
234
|
+
-# Parenthesis required due to Rails 3.0 deprecation of block helpers
|
235
|
+
-# that return strings.
|
236
|
+
- (with_output_buffer do
|
232
237
|
bar
|
233
238
|
= "foo".gsub(/./) do |s|
|
234
239
|
- "flup"
|
240
|
+
- end; nil)
|
235
241
|
baz
|
236
242
|
HAML
|
237
243
|
end
|
@@ -267,6 +273,28 @@ END
|
|
267
273
|
end
|
268
274
|
end
|
269
275
|
|
276
|
+
if defined?(ActionView::OutputBuffer) &&
|
277
|
+
Haml::Util.has?(:instance_method, ActionView::OutputBuffer, :append_if_string=)
|
278
|
+
def test_av_block_deprecation_warning
|
279
|
+
assert_warning(/^DEPRECATION WARNING: - style block helpers are deprecated\. Please use =\./) do
|
280
|
+
assert_equal <<HTML, render(<<HAML, :action_view)
|
281
|
+
<form action="" method="post">
|
282
|
+
Title:
|
283
|
+
<input id="article_title" name="article[title]" size="30" type="text" value="Hello" />
|
284
|
+
Body:
|
285
|
+
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
286
|
+
</form>
|
287
|
+
HTML
|
288
|
+
- form_for :article, @article, :url => '' do |f|
|
289
|
+
Title:
|
290
|
+
= f.text_field :title
|
291
|
+
Body:
|
292
|
+
= f.text_field :body
|
293
|
+
HAML
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
270
298
|
## XSS Protection Tests
|
271
299
|
|
272
300
|
# In order to enable these, either test against Rails 3.0
|
@@ -356,7 +384,7 @@ HAML
|
|
356
384
|
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
357
385
|
</form>
|
358
386
|
HTML
|
359
|
-
|
387
|
+
#{rails_block_helper_char} form_for :article, @article, :url => '' do |f|
|
360
388
|
Title:
|
361
389
|
= f.text_field :title
|
362
390
|
Body:
|
@@ -62,6 +62,19 @@ click
|
|
62
62
|
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
63
63
|
</form>
|
64
64
|
</div>
|
65
|
+
- elsif Haml::Util.ap_geq_3?
|
66
|
+
%p
|
67
|
+
= form_tag ''
|
68
|
+
%div
|
69
|
+
= form_tag '' do
|
70
|
+
%div= submit_tag 'save'
|
71
|
+
- @foo = 'value one'
|
72
|
+
= test_partial 'partial'
|
73
|
+
= form_for :article, @article, :url => '' do |f|
|
74
|
+
Title:
|
75
|
+
= f.text_field :title
|
76
|
+
Body:
|
77
|
+
= f.text_field :body
|
65
78
|
- else
|
66
79
|
%p
|
67
80
|
= form_tag ''
|
@@ -70,7 +70,9 @@
|
|
70
70
|
Nested content
|
71
71
|
%p.foo{:class => true ? 'bar' : 'baz'}[@article] Blah
|
72
72
|
%p.foo{:class => false ? 'bar' : ''}[@article] Blah
|
73
|
+
%p.foo{:class => %w[bar baz]}[@article] Blah
|
73
74
|
%p.qux{:class => 'quux'}[@article] Blump
|
75
|
+
%p#foo{:id => %w[bar baz]}[@article] Whee
|
74
76
|
== #{"Woah inner quotes"}
|
75
77
|
%p.dynamic_quote{:quotes => "single '", :dyn => 1 + 2}
|
76
78
|
%p.dynamic_self_closing{:dyn => 1 + 2}/
|
@@ -1,3 +1,7 @@
|
|
1
1
|
%h1 Partial layout used with for block:
|
2
|
-
-
|
3
|
-
|
2
|
+
- if Haml::Util.ap_geq_3?
|
3
|
+
= render :layout => 'layout_for_partial.haml' do
|
4
|
+
%p Some content within a layout
|
5
|
+
- else
|
6
|
+
- render :layout => 'layout_for_partial.haml' do
|
7
|
+
%p Some content within a layout
|
data/test/haml/util_test.rb
CHANGED
@@ -86,6 +86,11 @@ class UtilTest < Test::Unit::TestCase
|
|
86
86
|
enum_with_index(%w[foo bar baz]).map {|s, i| "#{s}#{i}"})
|
87
87
|
end
|
88
88
|
|
89
|
+
def test_ord
|
90
|
+
assert_equal(102, ord("f"))
|
91
|
+
assert_equal(98, ord("bar"))
|
92
|
+
end
|
93
|
+
|
89
94
|
def test_caller_info
|
90
95
|
assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'"))
|
91
96
|
assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12"))
|
data/test/sass/engine_test.rb
CHANGED
@@ -626,6 +626,81 @@ SASS
|
|
626
626
|
renders_correctly "line_numbers", :line_comments => true, :load_paths => [File.dirname(__FILE__) + "/templates"]
|
627
627
|
end
|
628
628
|
|
629
|
+
def test_debug_info
|
630
|
+
assert_equal(<<CSS, render(<<SASS, :debug_info => true, :style => :compact))
|
631
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0032 }}
|
632
|
+
foo bar { foo: bar; }
|
633
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0035 }}
|
634
|
+
foo baz { blip: blop; }
|
635
|
+
|
636
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0039 }}
|
637
|
+
floodle { flop: blop; }
|
638
|
+
|
639
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0031 8}}
|
640
|
+
bup { mix: on; }
|
641
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0031 5}}
|
642
|
+
bup mixin { moop: mup; }
|
643
|
+
|
644
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_inline\\.sass}line{font-family:\\0032 2}}
|
645
|
+
bip hop, skip hop { a: b; }
|
646
|
+
CSS
|
647
|
+
foo
|
648
|
+
bar
|
649
|
+
foo: bar
|
650
|
+
|
651
|
+
baz
|
652
|
+
blip: blop
|
653
|
+
|
654
|
+
|
655
|
+
floodle
|
656
|
+
|
657
|
+
flop: blop
|
658
|
+
|
659
|
+
=mxn
|
660
|
+
mix: on
|
661
|
+
mixin
|
662
|
+
moop: mup
|
663
|
+
|
664
|
+
bup
|
665
|
+
+mxn
|
666
|
+
|
667
|
+
bip, skip
|
668
|
+
hop
|
669
|
+
a: b
|
670
|
+
SASS
|
671
|
+
end
|
672
|
+
|
673
|
+
def test_debug_info_without_filename
|
674
|
+
assert_equal(<<CSS, Sass::Engine.new(<<SASS, :debug_info => true).render)
|
675
|
+
@media -sass-debug-info{filename{font-family:}line{font-family:\\0031 }}
|
676
|
+
foo {
|
677
|
+
a: b; }
|
678
|
+
CSS
|
679
|
+
foo
|
680
|
+
a: b
|
681
|
+
SASS
|
682
|
+
end
|
683
|
+
|
684
|
+
def test_debug_info_with_compressed
|
685
|
+
assert_equal(<<CSS, render(<<SASS, :debug_info => true, :style => :compressed))
|
686
|
+
foo{a:b}
|
687
|
+
CSS
|
688
|
+
foo
|
689
|
+
a: b
|
690
|
+
SASS
|
691
|
+
end
|
692
|
+
|
693
|
+
def test_debug_info_with_line_annotations
|
694
|
+
assert_equal(<<CSS, render(<<SASS, :debug_info => true, :line_comments => true))
|
695
|
+
@media -sass-debug-info{filename{font-family:file\\:\\/\\/\\/home\\/nex3\\/code\\/haml\\/test_debug_info_with_line_annotations_inline\\.sass}line{font-family:\\0031 }}
|
696
|
+
foo {
|
697
|
+
a: b; }
|
698
|
+
CSS
|
699
|
+
foo
|
700
|
+
a: b
|
701
|
+
SASS
|
702
|
+
end
|
703
|
+
|
629
704
|
def test_empty_first_line
|
630
705
|
assert_equal("#a {\n b: c; }\n", render("#a\n\n b: c"))
|
631
706
|
end
|
data/test/test_helper.rb
CHANGED
@@ -41,7 +41,12 @@ class Test::Unit::TestCase
|
|
41
41
|
def assert_warning(message)
|
42
42
|
the_real_stderr, $stderr = $stderr, StringIO.new
|
43
43
|
yield
|
44
|
-
|
44
|
+
|
45
|
+
if message.is_a?(Regexp)
|
46
|
+
assert_match message, $stderr.string.strip
|
47
|
+
else
|
48
|
+
assert_equal message.strip, $stderr.string.strip
|
49
|
+
end
|
45
50
|
ensure
|
46
51
|
$stderr = the_real_stderr
|
47
52
|
end
|
@@ -49,4 +54,9 @@ class Test::Unit::TestCase
|
|
49
54
|
def silence_warnings(&block)
|
50
55
|
Haml::Util.silence_warnings(&block)
|
51
56
|
end
|
57
|
+
|
58
|
+
def rails_block_helper_char
|
59
|
+
return '=' if Haml::Util.ap_geq_3?
|
60
|
+
return '-'
|
61
|
+
end
|
52
62
|
end
|
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.170
|
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: 2010-03-
|
13
|
+
date: 2010-03-20 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -64,13 +64,14 @@ files:
|
|
64
64
|
- lib/haml/helpers/xss_mods.rb
|
65
65
|
- lib/haml/html.rb
|
66
66
|
- lib/haml/precompiler.rb
|
67
|
+
- lib/haml/util.rb
|
67
68
|
- lib/haml/html/erb.rb
|
68
69
|
- lib/haml/shared.rb
|
69
70
|
- lib/haml/template.rb
|
70
71
|
- lib/haml/template/patch.rb
|
71
72
|
- lib/haml/template/plugin.rb
|
72
|
-
- lib/haml/util.rb
|
73
73
|
- lib/haml/version.rb
|
74
|
+
- lib/haml/railtie.rb
|
74
75
|
- lib/sass.rb
|
75
76
|
- lib/sass/css.rb
|
76
77
|
- lib/sass/engine.rb
|