Skip to content

Commit

Permalink
Test legacy template tags
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Jan 30, 2024
1 parent f8332e7 commit 06dcbc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/phlex/sgml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def template

def self.method_added(method_name)
if method_name == :template
warn "Defining the `template` method on a Phlex component is deprecated and will be unsupported in Phlex 2.0. Please define `view_template` instead."
Kernel.warn "Defining the `template` method on a Phlex component is deprecated and will be unsupported in Phlex 2.0. Please define `view_template` instead."
end
end

Expand Down
17 changes: 17 additions & 0 deletions test/phlex/view/legacy_template_method.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

describe Phlex::SGML do
it "warns when you define a template" do
expect(Kernel).to receive(:warn)

class Example < Phlex::HTML
def template
h1 { "Hello, world!" }
end
end

expect(
Example.new.call
).to be == "<h1>Hello, world!</h1>"
end
end

0 comments on commit 06dcbc3

Please sign in to comment.