We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4174470 + 7cfb0a0 commit f4d3daeCopy full SHA for f4d3dae
lib/sprockets/erb_processor.rb
@@ -18,8 +18,7 @@ def initialize(&block)
18
end
19
20
def call(input)
21
- match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
22
- if match && match[:version] >= "2.2.0" # Ruby 2.6+
+ if keyword_constructor? # Ruby 2.6+
23
engine = ::ERB.new(input[:data], trim_mode: '<>')
24
else
25
engine = ::ERB.new(input[:data], nil, '<>')
@@ -32,5 +31,12 @@ def call(input)
32
31
data = context._evaluate_template
33
context.metadata.merge(data: data)
34
+
35
+ private
36
37
+ def keyword_constructor?
38
+ return @keyword_constructor if defined? @keyword_constructor
39
+ @keyword_constructor = ::ERB.instance_method(:initialize).parameters.include?([:key, :trim_mode])
40
+ end
41
42
0 commit comments