haml 6.4.0 → 7.5.1

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/lib/haml/util.rb CHANGED
@@ -5,7 +5,6 @@ begin
5
5
  rescue LoadError
6
6
  require 'erb'
7
7
  end
8
- require 'set'
9
8
  require 'stringio'
10
9
  require 'strscan'
11
10
 
@@ -26,10 +25,9 @@ module Haml
26
25
  end
27
26
  end
28
27
 
29
- # TODO: Remove unescape_interpolation's workaround and get rid of `respond_to?`.
30
28
  def self.escape_html_safe(html)
31
29
  html = html.to_s
32
- (html.respond_to?(:html_safe?) && html.html_safe?) ? html : escape_html(html)
30
+ html.html_safe? ? html : escape_html(html)
33
31
  end
34
32
 
35
33
  # Silence all output to STDERR within a block.
@@ -69,7 +67,7 @@ module Haml
69
67
  # Shortcut for UTF-8 which might be the majority case
70
68
  if str.encoding == Encoding::UTF_8
71
69
  return str.gsub(/\A\uFEFF/, '')
72
- elsif str.encoding.name =~ /^UTF-(16|32)(BE|LE)?$/
70
+ elsif /^UTF-(16|32)(BE|LE)?$/.match?(str.encoding.name)
73
71
  return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding)), '')
74
72
  else
75
73
  return str
@@ -170,7 +168,7 @@ MSG
170
168
  # and the rest of the string.
171
169
  # `["Foo (Bar (Baz bang) bop)", " (Bang (bop bip))"]` in the example above.
172
170
  def balance(scanner, start, finish, count = 0)
173
- str = ''.dup
171
+ str = +''
174
172
  scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
175
173
  regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
176
174
  while scanner.scan(regexp)
@@ -202,8 +200,8 @@ MSG
202
200
  /#[\{$@]/ === str
203
201
  end
204
202
 
205
- def unescape_interpolation(str, escape_html = nil)
206
- res = ''.dup
203
+ def unescape_interpolation(str)
204
+ res = +''
207
205
  rest = Haml::Util.handle_interpolation str.dump do |scan|
208
206
  escapes = (scan[2].size - 1) / 2
209
207
  char = scan[3] # '{', '@' or '$'
@@ -218,12 +216,17 @@ MSG
218
216
  end
219
217
  content = eval("\"#{interpolated}\"")
220
218
  content = "#{char}#{content}" if char == '@' || char == '$'
221
- content = "Haml::Util.escape_html_safe((#{content}).to_s)" if escape_html
222
219
 
223
220
  res << "\#{#{content}}"
224
221
  end
225
222
  end
226
- res + rest
223
+ # The result is rebuilt from `str.dump` fragments and eval'd pieces, so it can
224
+ # come out tagged with an encoding that differs from `str`'s (e.g. UTF-8 for a
225
+ # BINARY source). The compiled template joins this string literal's fragments
226
+ # with fragments sliced out of the source itself, and mixed encodings raise
227
+ # Encoding::CompatibilityError, so bring it back to the source encoding.
228
+ # See haml/haml#1218.
229
+ (res + rest).force_encoding(str.encoding)
227
230
  end
228
231
 
229
232
  private
@@ -252,7 +255,7 @@ MSG
252
255
  # From Ruby's parse.y
253
256
  return unless scanner.scan(/([^\s'":;]+)\s*:\s*("(?:\\.|[^"])*"|[^"\s;]+?)[\s;]*-\*-/n)
254
257
  name, val = scanner[1], scanner[2]
255
- return unless name =~ /(en)?coding/in
258
+ return unless /(en)?coding/in.match?(name)
256
259
  val = $1 if val =~ /^"(.*)"$/n
257
260
  return val
258
261
  ensure
data/lib/haml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Haml
3
- VERSION = '6.4.0'
3
+ VERSION = '7.5.1'
4
4
  end
data/lib/haml.rb CHANGED
@@ -5,9 +5,5 @@ require 'haml/version'
5
5
  require 'haml/template'
6
6
 
7
7
  if File.basename($0) != 'haml'
8
- begin
9
- require 'rails'
10
- require 'haml/railtie'
11
- rescue LoadError
12
- end
8
+ require 'haml/railtie' if defined?(Rails::Railtie)
13
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 7.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natalie Weizenbaum
@@ -13,6 +13,20 @@ bindir: exe
13
13
  cert_chain: []
14
14
  date: 1980-01-02 00:00:00.000000000 Z
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: prism
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
16
30
  - !ruby/object:Gem::Dependency
17
31
  name: temple
18
32
  requirement: !ruby/object:Gem::Requirement
@@ -111,20 +125,6 @@ dependencies:
111
125
  - - ">="
112
126
  - !ruby/object:Gem::Version
113
127
  version: '0'
114
- - !ruby/object:Gem::Dependency
115
- name: haml
116
- requirement: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: '5'
121
- type: :development
122
- prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: '5'
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: less
130
130
  requirement: !ruby/object:Gem::Requirement
@@ -307,6 +307,7 @@ files:
307
307
  - lib/haml/identity.rb
308
308
  - lib/haml/object_ref.rb
309
309
  - lib/haml/parser.rb
310
+ - lib/haml/preserver.rb
310
311
  - lib/haml/rails_helpers.rb
311
312
  - lib/haml/rails_template.rb
312
313
  - lib/haml/railtie.rb
@@ -322,7 +323,10 @@ licenses:
322
323
  - MIT
323
324
  metadata:
324
325
  rubygems_mfa_required: 'true'
325
- changelog_uri: https://haml.info/blob/main/CHANGELOG.md
326
+ bug_tracker_uri: https://github.com/haml/haml/issues
327
+ changelog_uri: https://github.com/haml/haml/blob/main/CHANGELOG.md
328
+ homepage_uri: https://haml.info/
329
+ source_code_uri: https://github.com/haml/haml
326
330
  rdoc_options: []
327
331
  require_paths:
328
332
  - lib
@@ -330,7 +334,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
330
334
  requirements:
331
335
  - - ">="
332
336
  - !ruby/object:Gem::Version
333
- version: 2.1.0
337
+ version: 3.2.0
334
338
  required_rubygems_version: !ruby/object:Gem::Requirement
335
339
  requirements:
336
340
  - - ">="