diff --git a/Gemfile b/Gemfile index e1de4d2..e25493f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,6 @@ source "https://rubygems.org" gemspec gem "benchmark-ips", "2.13.0" -gem "minitest", "5.22.2" -gem "rake", "13.1.0" -gem "standard", "1.34.0" +gem "minitest", "5.22.3" +gem "rake", "13.2.1" +gem "standard", "1.35.1" diff --git a/benchmark/main.rb b/benchmark/main.rb index b850c85..c01b586 100644 --- a/benchmark/main.rb +++ b/benchmark/main.rb @@ -9,7 +9,7 @@ def initialize @items = [] end - def template + def view_template if @header h1(class: "header", &@header) end @@ -36,7 +36,7 @@ class SlotableList < Phlex::HTML slot :header slot :item, collection: true - def template + def view_template if header_slot h1(class: "header", &header_slot) end @@ -50,7 +50,7 @@ def template end class DeferredListExample < Phlex::HTML - def template + def view_template render DeferredList.new do |list| list.header do "Header" @@ -68,7 +68,7 @@ def template end class SlotableListExample < Phlex::HTML - def template + def view_template render SlotableList.new do |list| list.with_header do "Header" diff --git a/lib/phlex/slotable.rb b/lib/phlex/slotable.rb index 6c789bf..d5bf1a5 100644 --- a/lib/phlex/slotable.rb +++ b/lib/phlex/slotable.rb @@ -44,7 +44,7 @@ def with_#{slot_name_with_type}#{signature} RUBY end - class_eval(setter_method, __FILE__, __LINE__ + 1) + class_eval(setter_method, __FILE__, __LINE__) define_lambda_method(slot_name_with_type, callable) if callable.is_a?(Proc) end @@ -70,7 +70,7 @@ def #{slot_name}_slot RUBY end - class_eval(getter_method, __FILE__, __LINE__ + 1) + class_eval(getter_method, __FILE__, __LINE__) end def define_predicate_method(slot_name, collection:) @@ -90,7 +90,7 @@ def #{slot_name}_slot? RUBY end - class_eval(predicate_method, __FILE__, __LINE__ + 1) + class_eval(predicate_method, __FILE__, __LINE__) end def callable_value(slot_name, callable) diff --git a/phlex-slotable.gemspec b/phlex-slotable.gemspec index 55b2584..cc18378 100644 --- a/phlex-slotable.gemspec +++ b/phlex-slotable.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] # Uncomment to register a new dependency of your gem - spec.add_dependency "phlex", ">= 1.9" + spec.add_dependency "phlex", "~> 1.9" # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/test/phlex/test_component_slot_collection.rb b/test/phlex/test_component_slot_collection.rb index 586e066..7ed6570 100644 --- a/test/phlex/test_component_slot_collection.rb +++ b/test/phlex/test_component_slot_collection.rb @@ -8,7 +8,7 @@ def initialize(featured: false) @featured = featured end - def template(&content) + def view_template(&content) p(class: @featured ? "featured" : nil, &content) end end @@ -18,7 +18,7 @@ class Blog < Phlex::HTML slot :post, PostComponent, collection: true - def template + def view_template if post_slots? main do post_slots.each do |slot| diff --git a/test/phlex/test_component_string_slot_collection.rb b/test/phlex/test_component_string_slot_collection.rb index 6c1725c..bac4177 100644 --- a/test/phlex/test_component_string_slot_collection.rb +++ b/test/phlex/test_component_string_slot_collection.rb @@ -8,7 +8,7 @@ class Blog < Phlex::HTML slot :post, "PostComponent", collection: true - def template + def view_template if post_slots? main do post_slots.each do |slot| @@ -27,7 +27,7 @@ def initialize(featured: false) @featured = featured end - def template(&content) + def view_template(&content) p(class: @featured ? "featured" : nil, &content) end end diff --git a/test/phlex/test_generic_slot_collection.rb b/test/phlex/test_generic_slot_collection.rb index 1b749d3..e15977b 100644 --- a/test/phlex/test_generic_slot_collection.rb +++ b/test/phlex/test_generic_slot_collection.rb @@ -8,7 +8,7 @@ class Blog < Phlex::HTML slot :post, collection: true - def template + def view_template if post_slots? main do post_slots.each do |slot| diff --git a/test/phlex/test_lambda_slot_collection.rb b/test/phlex/test_lambda_slot_collection.rb index 754168b..ac3dc9b 100644 --- a/test/phlex/test_lambda_slot_collection.rb +++ b/test/phlex/test_lambda_slot_collection.rb @@ -14,7 +14,7 @@ def initialize(size:, bg_color:) @bg_color = bg_color end - def template + def view_template div class: "headline text-#{@size} bg-#{@bg_color}" do render icon_slot render title_slot @@ -34,7 +34,7 @@ def initialize(headline_bg_color: nil) @headline_bg_color = headline_bg_color end - def template + def view_template if post_slots? main do headline_slots.each do |slot| diff --git a/test/phlex/test_polymorphic_slot_collection.rb b/test/phlex/test_polymorphic_slot_collection.rb index 0763952..a2680ed 100644 --- a/test/phlex/test_polymorphic_slot_collection.rb +++ b/test/phlex/test_polymorphic_slot_collection.rb @@ -8,7 +8,7 @@ def initialize(src:) @src = src end - def template + def view_template img(class: "image", src: @src) end end @@ -24,7 +24,7 @@ class UsersList < Phlex::HTML end } - def template + def view_template if avatar_slots? div id: "users" do avatar_slots.each { |slot| render slot } @@ -41,7 +41,7 @@ def initialize(name:) @name = name end - def template + def view_template i(class: @name) end end diff --git a/test/phlex/test_single_component_slot.rb b/test/phlex/test_single_component_slot.rb index dcf46a4..41b8bae 100644 --- a/test/phlex/test_single_component_slot.rb +++ b/test/phlex/test_single_component_slot.rb @@ -8,7 +8,7 @@ def initialize(size:) @size = size end - def template(&content) + def view_template(&content) h1(class: "text-#{@size}", &content) end end @@ -18,7 +18,7 @@ class Blog < Phlex::HTML slot :header, HeaderComponent - def template + def view_template if header_slot? div id: "header" do render header_slot if header_slot? diff --git a/test/phlex/test_single_component_string_slot.rb b/test/phlex/test_single_component_string_slot.rb index c8e0075..af196a0 100644 --- a/test/phlex/test_single_component_string_slot.rb +++ b/test/phlex/test_single_component_string_slot.rb @@ -8,7 +8,7 @@ class Blog < Phlex::HTML slot :header, "HeaderComponent" - def template + def view_template if header_slot? div id: "header" do render header_slot if header_slot? @@ -25,7 +25,7 @@ def initialize(size:) @size = size end - def template(&content) + def view_template(&content) h1(class: "text-#{@size}", &content) end end diff --git a/test/phlex/test_single_generic_slot.rb b/test/phlex/test_single_generic_slot.rb index 60bbbc2..453d0a2 100644 --- a/test/phlex/test_single_generic_slot.rb +++ b/test/phlex/test_single_generic_slot.rb @@ -8,7 +8,7 @@ class Blog < Phlex::HTML slot :header - def template + def view_template if header_slot? div id: "header" do render header_slot diff --git a/test/phlex/test_single_lambda_slot.rb b/test/phlex/test_single_lambda_slot.rb index f05d6f7..07a8a5a 100644 --- a/test/phlex/test_single_lambda_slot.rb +++ b/test/phlex/test_single_lambda_slot.rb @@ -14,7 +14,7 @@ def initialize(size:, bg_color:) @bg_color = bg_color end - def template(&content) + def view_template(&content) h3(class: "text-#{@size} bg-#{@bg_color}") do render icon_slot render content_slot @@ -34,7 +34,7 @@ def initialize(subtitle_bg_color: nil) @subtitle_bg_color = subtitle_bg_color end - def template + def view_template div id: "header" do render title_slot if title_slot? render subtitle_slot if subtitle_slot? diff --git a/test/phlex/test_single_polymorphic_slot.rb b/test/phlex/test_single_polymorphic_slot.rb index 8af9be2..4629cc0 100644 --- a/test/phlex/test_single_polymorphic_slot.rb +++ b/test/phlex/test_single_polymorphic_slot.rb @@ -8,7 +8,7 @@ def initialize(src:) @src = src end - def template + def view_template img(class: "image", src: @src) end end @@ -24,7 +24,7 @@ class ProfileCard < Phlex::HTML end } - def template + def view_template if avatar_slot? div id: "avatar" do render avatar_slot @@ -41,7 +41,7 @@ def initialize(name:) @name = name end - def template + def view_template i(class: @name) end end