Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove p shorthand deprecated in #39 #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/nice_partials/monkey_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ 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
ActionView::Base.prepend self

Expand All @@ -37,15 +34,6 @@ def __partials
end
delegate :partial, to: :__partials

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

# Overrides `ActionView::Helpers::RenderingHelper#render` to push a new `nice_partial`
# on the stack, so rendering has a fresh `partial` to store content in.
def render(*)
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 @@ -82,20 +82,4 @@ class RendererTest < NicePartials::Test
assert_css "#yielded_object", text: "slot content"
end
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_text "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