Skip to content

Commit

Permalink
Fix Ruby 3.1 deprecation warning with ERB.new (#1108)
Browse files Browse the repository at this point in the history
* Fix Ruby 3.1 deprecation warning with ERB.new

This eliminates the warning:

```
warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
```

Per https://bugs.ruby-lang.org/issues/14256, `trim_mode` needs to be a
keyword argument. This is compatible with Ruby 2.7 and on.

Signed-off-by: Stan Hu <stanhu@gmail.com>

* Remove safe_level argument as it's deprecated too

Signed-off-by: Vikram Karve <vikram.karve@progress.com>

---------

Signed-off-by: Stan Hu <stanhu@gmail.com>
Signed-off-by: Vikram Karve <vikram.karve@progress.com>
Co-authored-by: Vikram Karve <85881329+vkarve-chef@users.noreply.github.com>
  • Loading branch information
stanhu and vkarve-chef committed Jun 13, 2023
1 parent 7f52614 commit ee25ccf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/omnibus/templating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def self.included(base)
# the list of variables to pass to the template
#
def render_template_content(source, variables = {})
template = ERB.new(File.read(source), nil, "-")

template = ERB.new(File.read(source), trim_mode: "-")
struct =
if variables.empty?
Struct.new("Empty")
Expand Down

0 comments on commit ee25ccf

Please sign in to comment.