haml-edge 2.3.76 → 2.3.77

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.
Files changed (4) hide show
  1. data/EDGE_GEM_VERSION +1 -1
  2. data/VERSION +1 -1
  3. data/lib/haml/html.rb +15 -11
  4. metadata +1 -1
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.76
1
+ 2.3.77
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.76
1
+ 2.3.77
data/lib/haml/html.rb CHANGED
@@ -62,6 +62,10 @@ module Haml
62
62
  text.gsub('#{', '\#{') #'
63
63
  end
64
64
 
65
+ def attr_hash
66
+ attributes.to_hash
67
+ end
68
+
65
69
  def parse_text(text, tabs)
66
70
  parse_text_with_interpolation(uninterp(text), tabs)
67
71
  end
@@ -224,8 +228,8 @@ module Haml
224
228
  def to_haml(tabs, options)
225
229
  return "" if converted_to_haml
226
230
  if name == "script" &&
227
- (attributes['type'].nil? || attributes['type'] == "text/javascript") &&
228
- (attributes.keys - ['type']).empty?
231
+ (attr_hash['type'].nil? || attr_hash['type'] == "text/javascript") &&
232
+ (attr_hash.keys - ['type']).empty?
229
233
  return script_to_haml(tabs, options)
230
234
  end
231
235
 
@@ -269,22 +273,22 @@ module Haml
269
273
  output << "%#{name}" unless name == 'div' &&
270
274
  (static_id?(options) ||
271
275
  static_classname?(options) &&
272
- attributes['class'].split(' ').any?(&method(:haml_css_attr?)))
276
+ attr_hash['class'].split(' ').any?(&method(:haml_css_attr?)))
273
277
 
274
- if attributes
278
+ if attr_hash
275
279
  if static_id?(options)
276
- output << "##{attributes['id']}"
280
+ output << "##{attr_hash['id']}"
277
281
  remove_attribute('id')
278
282
  end
279
283
  if static_classname?(options)
280
- leftover = attributes['class'].split(' ').reject do |c|
284
+ leftover = attr_hash['class'].split(' ').reject do |c|
281
285
  next unless haml_css_attr?(c)
282
286
  output << ".#{c}"
283
287
  end
284
288
  remove_attribute('class')
285
289
  set_attribute('class', leftover.join(' ')) unless leftover.empty?
286
290
  end
287
- output << haml_attributes(options) if attributes.length > 0
291
+ output << haml_attributes(options) if attr_hash.length > 0
288
292
  end
289
293
 
290
294
  output << "/" if empty? && !etag
@@ -319,7 +323,7 @@ module Haml
319
323
 
320
324
  def dynamic_attributes
321
325
  @dynamic_attributes ||= begin
322
- Haml::Util.map_hash(attributes) do |name, value|
326
+ Haml::Util.map_hash(attr_hash) do |name, value|
323
327
  next if value.empty?
324
328
  full_match = nil
325
329
  ruby_value = value.gsub(%r{<haml:loud>\s*(.+?)\s*</haml:loud>}) do
@@ -351,7 +355,7 @@ module Haml
351
355
  end
352
356
 
353
357
  def static_attribute?(name, options)
354
- attributes[name] && !dynamic_attribute?(name, options)
358
+ attr_hash[name] && !dynamic_attribute?(name, options)
355
359
  end
356
360
 
357
361
  def dynamic_attribute?(name, options)
@@ -359,7 +363,7 @@ module Haml
359
363
  end
360
364
 
361
365
  def static_id?(options)
362
- static_attribute?('id', options) && haml_css_attr?(attributes['id'])
366
+ static_attribute?('id', options) && haml_css_attr?(attr_hash['id'])
363
367
  end
364
368
 
365
369
  def static_classname?(options)
@@ -373,7 +377,7 @@ module Haml
373
377
  # Returns a string representation of an attributes hash
374
378
  # that's prettier than that produced by Hash#inspect
375
379
  def haml_attributes(options)
376
- attrs = attributes.sort.map do |name, value|
380
+ attrs = attr_hash.sort.map do |name, value|
377
381
  value = dynamic_attribute?(name, options) ? dynamic_attributes[name] : value.inspect
378
382
  name = name.index(/\W/) ? name.inspect : ":#{name}"
379
383
  "#{name} => #{value}"
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.76
4
+ version: 2.3.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum