Skip to content

Commit

Permalink
Remove p shorthand deprecated in #39
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspth committed Jul 3, 2022
1 parent f281083 commit 60d4ac2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
12 changes: 0 additions & 12 deletions lib/nice_partials/monkey_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,9 @@ def with_nice_partials_t_prefix(lookup_context, block)
end
end

require "active_support/deprecation"
NicePartials::DEPRECATOR = ActiveSupport::Deprecation.new("1.0", "nice_partials")

module NicePartials::RenderingWithAutoContext
attr_reader :partial

def p(*args)
if args.empty?
NicePartials::DEPRECATOR.deprecation_warning :p, :partial # In-branch printing so we don't warn on legit `Kernel.p` calls.
partial
else
super # …we're really Kernel.p
end
end

def render(options = {}, locals = {}, &block)
_partial, @partial = partial, nice_partial
@partial.capture(block)
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/_clobberer.html.erb

This file was deleted.

16 changes: 0 additions & 16 deletions test/renderer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,4 @@ class RendererTest < NicePartials::Test
assert_rendered "hello from nice partials"
assert_equal "Some extra content", nice_partial.output_buffer
end

test "doesn't clobber Kernel.p" do
assert_output "\"it's clobbering time\"\n" do
render("clobberer") { |p| p.content_for :message, "hello from nice partials" }
end

assert_rendered "hello from nice partials"
end

test "deprecates top-level access through p method" do
assert_deprecated /p is deprecated and will be removed from nice_partials \d/, NicePartials::DEPRECATOR do
assert_output "\"it's clobbering time\"\n" do
render("clobberer") { |p| p.content_for :message, "hello from nice partials" }
end
end
end
end

0 comments on commit 60d4ac2

Please sign in to comment.