haml 2.2.23 → 2.2.24
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +1 -0
- data/REMEMBER +1 -12
- data/Rakefile +24 -2
- data/VERSION +1 -1
- data/lib/haml/filters.rb +2 -0
- data/lib/haml/helpers.rb +2 -9
- data/lib/haml/helpers/action_view_extensions.rb +4 -2
- data/lib/haml/helpers/action_view_mods.rb +6 -4
- data/lib/haml/precompiler.rb +1 -0
- data/lib/haml/railtie.rb +5 -1
- data/lib/haml/template.rb +13 -3
- data/lib/haml/util.rb +28 -0
- data/lib/sass/script/number.rb +2 -2
- data/lib/sass/tree/if_node.rb +1 -0
- data/lib/sass/tree/rule_node.rb +9 -1
- data/test/haml/helper_test.rb +25 -2
- data/test/haml/template_test.rb +2 -2
- data/test/haml/templates/helpers.haml +13 -0
- data/test/test_helper.rb +5 -0
- metadata +3 -3
data/.yardopts
CHANGED
data/REMEMBER
CHANGED
@@ -1,13 +1,2 @@
|
|
1
|
-
Deprecate .foo& in stable
|
2
|
-
Make .#{} work in extend
|
3
|
-
Test newly-invalid selectors, including post-resolution parse errors in Sass
|
4
1
|
Be smart about default namespaces (http://www.w3.org/TR/css3-namespace/#declaration)
|
5
|
-
|
6
|
-
|
7
|
-
http://camendesign.com/design/ provides some interesting formatting and nesting issues for sass-convert
|
8
|
-
Charles Roper's example code for media queries doesn't fare well in css2sass either
|
9
|
-
|
10
|
-
Add period to SCSS syntax errors?
|
11
|
-
Better #{} in prop names
|
12
|
-
Faster than Less
|
13
|
-
Comma multiline for Haml
|
2
|
+
Extending nested selectors?
|
data/Rakefile
CHANGED
@@ -226,7 +226,7 @@ end
|
|
226
226
|
begin
|
227
227
|
require 'yard'
|
228
228
|
|
229
|
-
namespace :
|
229
|
+
namespace :doc do
|
230
230
|
task :sass do
|
231
231
|
require scope('lib/sass')
|
232
232
|
Dir[scope("yard/default/**/*.sass")].each do |sass|
|
@@ -235,12 +235,27 @@ begin
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
end
|
238
|
+
|
239
|
+
desc "List all undocumented methods and classes."
|
240
|
+
task :undocumented do
|
241
|
+
opts = ENV["YARD_OPTS"] || ""
|
242
|
+
ENV["YARD_OPTS"] = opts.dup + <<OPTS
|
243
|
+
--list --query "
|
244
|
+
object.docstring.blank? &&
|
245
|
+
!(object.type == :method && object.is_alias?)"
|
246
|
+
OPTS
|
247
|
+
Rake::Task['yard'].execute
|
248
|
+
end
|
238
249
|
end
|
239
250
|
|
240
251
|
YARD::Rake::YardocTask.new do |t|
|
241
252
|
t.files = FileList.new(scope('lib/**/*.rb')) do |list|
|
242
253
|
list.exclude('lib/haml/template/*.rb')
|
254
|
+
list.exclude('lib/haml/railtie.rb')
|
243
255
|
list.exclude('lib/haml/helpers/action_view_mods.rb')
|
256
|
+
list.exclude('lib/haml/helpers/xss_mods.rb')
|
257
|
+
list.exclude('lib/sass/plugin/merb.rb')
|
258
|
+
list.exclude('lib/sass/plugin/rails.rb')
|
244
259
|
end.to_a
|
245
260
|
t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
|
246
261
|
t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
|
@@ -248,8 +263,15 @@ begin
|
|
248
263
|
t.options << '--files' << files.join(',')
|
249
264
|
t.options << '--template-path' << scope('yard')
|
250
265
|
t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
|
266
|
+
|
267
|
+
t.before = lambda do
|
268
|
+
if ENV["YARD_OPTS"]
|
269
|
+
require 'shellwords'
|
270
|
+
t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
|
271
|
+
end
|
272
|
+
end
|
251
273
|
end
|
252
|
-
Rake::Task['yard'].prerequisites.insert(0, '
|
274
|
+
Rake::Task['yard'].prerequisites.insert(0, 'doc:sass')
|
253
275
|
Rake::Task['yard'].instance_variable_set('@comment', nil)
|
254
276
|
|
255
277
|
desc "Generate Documentation"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.24
|
data/lib/haml/filters.rb
CHANGED
data/lib/haml/helpers.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
if defined?(ActionView)
|
2
|
-
require 'haml/helpers/action_view_mods'
|
3
|
-
require 'haml/helpers/action_view_extensions'
|
4
|
-
end
|
5
|
-
|
6
1
|
module Haml
|
7
2
|
# This module contains various helpful methods to make it easier to do various tasks.
|
8
3
|
# {Haml::Helpers} is automatically included in the context
|
@@ -52,8 +47,7 @@ MESSAGE
|
|
52
47
|
|
53
48
|
self.extend self
|
54
49
|
|
55
|
-
@@action_view_defined =
|
56
|
-
@@force_no_action_view = false
|
50
|
+
@@action_view_defined = false
|
57
51
|
|
58
52
|
# @return [Boolean] Whether or not ActionView is loaded
|
59
53
|
def self.action_view?
|
@@ -572,11 +566,10 @@ END
|
|
572
566
|
_erbout = _hamlout.buffer
|
573
567
|
proc { |*args| proc.call(*args) }
|
574
568
|
end
|
575
|
-
|
576
|
-
include ActionViewExtensions if self.const_defined? "ActionViewExtensions"
|
577
569
|
end
|
578
570
|
end
|
579
571
|
|
572
|
+
# @private
|
580
573
|
class Object
|
581
574
|
# Haml overrides various `ActionView` helpers,
|
582
575
|
# which call an \{#is\_haml?} method
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'haml/helpers/action_view_mods'
|
2
|
-
|
3
1
|
module Haml
|
4
2
|
module Helpers
|
3
|
+
@@action_view_defined = true
|
4
|
+
|
5
5
|
# This module contains various useful helper methods
|
6
6
|
# that either tie into ActionView or the rest of the ActionPack stack,
|
7
7
|
# or are only useful in that context.
|
@@ -51,5 +51,7 @@ module Haml
|
|
51
51
|
@_haml_concat_raw = old
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
include ActionViewExtensions
|
54
56
|
end
|
55
57
|
end
|
@@ -126,7 +126,11 @@ module ActionView
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def content_tag(*args)
|
129
|
-
content_tag_with_haml(*args)
|
129
|
+
html_tag = content_tag_with_haml(*args)
|
130
|
+
return html_tag unless respond_to?(:error_wrapping)
|
131
|
+
return error_wrapping(html_tag) if method(:error_wrapping).arity == 1
|
132
|
+
return html_tag unless object.respond_to?(:errors) && object.errors.respond_to?(:on)
|
133
|
+
return error_wrapping(html_tag, object.errors.on(@method_name))
|
130
134
|
end
|
131
135
|
end
|
132
136
|
|
@@ -156,9 +160,7 @@ module ActionView
|
|
156
160
|
def form_for_with_haml(object_name, *args, &proc)
|
157
161
|
if block_given? && is_haml?
|
158
162
|
oldproc = proc
|
159
|
-
proc =
|
160
|
-
with_tabs(1) {oldproc.call(*args)}
|
161
|
-
end
|
163
|
+
proc = proc {|*args| with_tabs(1) {oldproc.call(*args)}}
|
162
164
|
end
|
163
165
|
res = form_for_without_haml(object_name, *args, &proc)
|
164
166
|
res << "\n" if block_given? && is_haml?
|
data/lib/haml/precompiler.rb
CHANGED
data/lib/haml/railtie.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
# Yehuda promises there will be soon,
|
4
4
|
# and once there is we should switch to that.
|
5
5
|
|
6
|
-
if defined?(
|
6
|
+
if defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)
|
7
|
+
# Rails 3.0.0.beta.2+
|
8
|
+
ActiveSupport.on_load(:action_view) {Haml.init_rails(binding)}
|
9
|
+
elsif defined?(Rails::Railtie)
|
10
|
+
# Rails 3.0.0.beta1
|
7
11
|
module Haml
|
8
12
|
class Railtie < Rails::Railtie
|
9
13
|
initializer :haml do
|
data/lib/haml/template.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'haml/engine'
|
2
|
+
require 'haml/helpers/action_view_mods'
|
3
|
+
require 'haml/helpers/action_view_extensions'
|
2
4
|
|
3
5
|
module Haml
|
4
6
|
# The class that keeps track of the global options for Haml within Rails.
|
@@ -17,7 +19,11 @@ module Haml
|
|
17
19
|
#
|
18
20
|
# @return [Boolean] Whether the XSS integration was enabled.
|
19
21
|
def try_enabling_xss_integration
|
20
|
-
return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?
|
22
|
+
return false unless (ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?) ||
|
23
|
+
# We check for ActiveSupport#on_load here because if we're loading Haml that way, it means:
|
24
|
+
# A) we're in Rails 3 so XSS support is always on, and
|
25
|
+
# B) we might be in Rails 3 beta 3 where the load order is broken and xss_safe? is undefined
|
26
|
+
(defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load))
|
21
27
|
|
22
28
|
Haml::Template.options[:escape_html] = true
|
23
29
|
|
@@ -53,10 +59,14 @@ else
|
|
53
59
|
require 'haml/template/patch'
|
54
60
|
end
|
55
61
|
|
56
|
-
# Enable XSS integration. Use Rails' after_initialize method
|
62
|
+
# Enable XSS integration. Use Rails' after_initialize method
|
57
63
|
# so that integration will be checked after the rails_xss plugin is loaded
|
58
64
|
# (for Rails 2.3.* where it's not enabled by default).
|
59
|
-
|
65
|
+
#
|
66
|
+
# If we're running under Rails 3, though, we don't want to use after_intialize,
|
67
|
+
# since Haml loading has already been deferred via ActiveSupport.on_load.
|
68
|
+
if defined?(Rails.configuration.after_initialize) &&
|
69
|
+
!(defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load))
|
60
70
|
Rails.configuration.after_initialize {Haml::Template.try_enabling_xss_integration}
|
61
71
|
else
|
62
72
|
Haml::Template.try_enabling_xss_integration
|
data/lib/haml/util.rb
CHANGED
@@ -182,6 +182,30 @@ module Haml
|
|
182
182
|
ActionPack::VERSION::TINY == "0.beta")
|
183
183
|
end
|
184
184
|
|
185
|
+
# Returns whether this environment is using ActionPack
|
186
|
+
# version 3.0.0.beta.3 or greater.
|
187
|
+
#
|
188
|
+
# @return [Boolean]
|
189
|
+
def ap_geq_3_beta_3?
|
190
|
+
# The ActionPack module is always loaded automatically in Rails >= 3
|
191
|
+
return false unless defined?(ActionPack) && defined?(ActionPack::VERSION)
|
192
|
+
|
193
|
+
version =
|
194
|
+
if defined?(ActionPack::VERSION::MAJOR)
|
195
|
+
ActionPack::VERSION::MAJOR
|
196
|
+
else
|
197
|
+
# Rails 1.2
|
198
|
+
ActionPack::VERSION::Major
|
199
|
+
end
|
200
|
+
version >= 3 &&
|
201
|
+
((defined?(ActionPack::VERSION::TINY) &&
|
202
|
+
ActionPack::VERSION::TINY.is_a?(Fixnum) &&
|
203
|
+
ActionPack::VERSION::TINY >= 1) ||
|
204
|
+
(defined?(ActionPack::VERSION::BUILD) &&
|
205
|
+
ActionPack::VERSION::BUILD =~ /beta(\d+)/ &&
|
206
|
+
$1.to_i >= 3))
|
207
|
+
end
|
208
|
+
|
185
209
|
# Returns an ActionView::Template* class.
|
186
210
|
# In pre-3.0 versions of Rails, most of these classes
|
187
211
|
# were of the form `ActionView::TemplateFoo`,
|
@@ -227,6 +251,10 @@ module Haml
|
|
227
251
|
raise Haml::Error.new("Expected #{text.inspect} to be HTML-safe.")
|
228
252
|
end
|
229
253
|
|
254
|
+
# The class for the Rails SafeBuffer XSS protection class.
|
255
|
+
# This varies depending on Rails version.
|
256
|
+
#
|
257
|
+
# @return [Class]
|
230
258
|
def rails_safe_buffer_class
|
231
259
|
return ActionView::SafeBuffer if defined?(ActionView::SafeBuffer)
|
232
260
|
ActiveSupport::SafeBuffer
|
data/lib/sass/script/number.rb
CHANGED
@@ -106,7 +106,7 @@ module Sass::Script
|
|
106
106
|
# @raise [NoMethodError] if `other` is an invalid type
|
107
107
|
def times(other)
|
108
108
|
if other.is_a? Number
|
109
|
-
|
109
|
+
operate(other, :*)
|
110
110
|
elsif other.is_a? Color
|
111
111
|
other.times(self)
|
112
112
|
else
|
@@ -284,7 +284,7 @@ module Sass::Script
|
|
284
284
|
end, num_units, den_units)
|
285
285
|
end
|
286
286
|
|
287
|
-
|
287
|
+
private
|
288
288
|
|
289
289
|
def operate(other, operation)
|
290
290
|
this = self
|
data/lib/sass/tree/if_node.rb
CHANGED
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -202,7 +202,15 @@ module Sass::Tree
|
|
202
202
|
while scanner.rest?
|
203
203
|
rules.last << scanner.scan(/[^",&]*/)
|
204
204
|
case scanner.scan(/./)
|
205
|
-
when '&'
|
205
|
+
when '&'
|
206
|
+
warn <<END unless rules.last.empty? || rules.last.last =~ /(^|\s)$/
|
207
|
+
DEPRECATION WARNING:
|
208
|
+
On line #{@line}#{" of '#{@filename}'" if @filename}
|
209
|
+
In Sass 3, parent selectors will only be able to appear
|
210
|
+
at the beginning of simple selector sequences.
|
211
|
+
For example, ".foo &.bar" is allowed but ".bar&" is not.
|
212
|
+
END
|
213
|
+
rules.last << :parent
|
206
214
|
when ','
|
207
215
|
scanner.scan(/\s*/)
|
208
216
|
rules << [] if scanner.rest?
|
data/test/haml/helper_test.rb
CHANGED
@@ -15,7 +15,18 @@ module Haml::Helpers
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class HelperTest < Test::Unit::TestCase
|
18
|
-
Post = Struct.new('Post', :body)
|
18
|
+
Post = Struct.new('Post', :body, :error_field, :errors)
|
19
|
+
class PostErrors
|
20
|
+
def on(name)
|
21
|
+
return unless name == 'error_field'
|
22
|
+
["Really bad error"]
|
23
|
+
end
|
24
|
+
alias_method :full_messages, :on
|
25
|
+
|
26
|
+
def [](name)
|
27
|
+
on(name) || []
|
28
|
+
end
|
29
|
+
end
|
19
30
|
|
20
31
|
def setup
|
21
32
|
@base = ActionView::Base.new
|
@@ -26,7 +37,7 @@ class HelperTest < Test::Unit::TestCase
|
|
26
37
|
@base.controller.response = ActionController::Response.new
|
27
38
|
end
|
28
39
|
|
29
|
-
@base.instance_variable_set('@post', Post.new("Foo bar\nbaz"))
|
40
|
+
@base.instance_variable_set('@post', Post.new("Foo bar\nbaz", nil, PostErrors.new))
|
30
41
|
end
|
31
42
|
|
32
43
|
def render(text, options = {})
|
@@ -153,6 +164,18 @@ HTML
|
|
153
164
|
HAML
|
154
165
|
end
|
155
166
|
|
167
|
+
def test_content_tag_error_wrapping
|
168
|
+
def @base.protect_against_forgery?; false; end
|
169
|
+
assert_equal(<<HTML, render(<<HAML, :action_view))
|
170
|
+
<form action="" method="post">
|
171
|
+
<div class="fieldWithErrors"><label for="post_error_field">Error field</label></div>
|
172
|
+
</form>
|
173
|
+
HTML
|
174
|
+
#{rails_block_helper_char} form_for #{form_for_calling_convention('post')}, :url => '' do |f|
|
175
|
+
= f.label 'error_field'
|
176
|
+
HAML
|
177
|
+
end
|
178
|
+
|
156
179
|
def test_haml_tag_attribute_html_escaping
|
157
180
|
assert_equal("<p id='foo&bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
|
158
181
|
end
|
data/test/haml/template_test.rb
CHANGED
@@ -268,7 +268,7 @@ END
|
|
268
268
|
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
269
269
|
</form>
|
270
270
|
HTML
|
271
|
-
- form_for :article,
|
271
|
+
- form_for #{form_for_calling_convention(:article)}, :url => '' do |f|
|
272
272
|
Title:
|
273
273
|
= f.text_field :title
|
274
274
|
Body:
|
@@ -367,7 +367,7 @@ HAML
|
|
367
367
|
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
368
368
|
</form>
|
369
369
|
HTML
|
370
|
-
#{rails_block_helper_char} form_for :article,
|
370
|
+
#{rails_block_helper_char} form_for #{form_for_calling_convention(:article)}, :url => '' do |f|
|
371
371
|
Title:
|
372
372
|
= f.text_field :title
|
373
373
|
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_beta_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, :as => :article, :url => '', :html => {:class => nil, :id => nil} do |f|
|
74
|
+
Title:
|
75
|
+
= f.text_field :title
|
76
|
+
Body:
|
77
|
+
= f.text_field :body
|
65
78
|
- elsif Haml::Util.ap_geq_3?
|
66
79
|
%p
|
67
80
|
= form_tag ''
|
data/test/test_helper.rb
CHANGED
@@ -42,4 +42,9 @@ class Test::Unit::TestCase
|
|
42
42
|
return '=' if Haml::Util.ap_geq_3?
|
43
43
|
return '-'
|
44
44
|
end
|
45
|
+
|
46
|
+
def form_for_calling_convention(name)
|
47
|
+
return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3_beta_3?
|
48
|
+
return ":#{name}, @#{name}"
|
49
|
+
end
|
45
50
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 2.2.
|
8
|
+
- 24
|
9
|
+
version: 2.2.24
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nathan Weizenbaum
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-27 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|