Skip to content

Commit

Permalink
[rails6] Update ActionView::Template::Handlers::RJS.call
Browse files Browse the repository at this point in the history
In Rails6, there is a deprecation warning with `.call` when working with
template handlers:

    DEPRECATION WARNING: Single arity template handlers are deprecated.
    Template handlers must now accept two parameters, the view object and the
    source for the view object.
    Change:
      >> #<ActionView::Template::Handlers::RJS:0x00007f8ecf616cb8>.call(template)
    To:
      >> #<ActionView::Template::Handlers::RJS:0x00007f8ecf616cb8>.call(template, source)

This borrows from PR 138 in Hamlit that did the same thing:

- https://github.com/k0kubun/hamlit
- https://github.com/k0kubun/hamlit/blob/master/CHANGELOG.md#293---2019-04-09
  • Loading branch information
NickLaMuro committed Nov 23, 2020
1 parent ded3d28 commit 1b33682
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/action_view/template/handlers/rjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class RJS
class_attribute :default_format
self.default_format = Mime[:js]

def call(template)
"update_page do |page|;#{template.source}\nend"
def call(template, source=nil)
source ||= template.source
"update_page do |page|;#{source}\nend"
end
end
end
Expand Down

0 comments on commit 1b33682

Please sign in to comment.