Skip to content

Commit

Permalink
Clean up some code (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Apr 5, 2024
1 parent 9b84fd1 commit c109625
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions benchmark/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize
@items = []
end

def template
def view_template
if @header
h1(class: "header", &@header)
end
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions lib/phlex/slotable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion phlex-slotable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_component_slot_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_component_string_slot_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/phlex/test_generic_slot_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_lambda_slot_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand Down
6 changes: 3 additions & 3 deletions test/phlex/test_polymorphic_slot_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(src:)
@src = src
end

def template
def view_template
img(class: "image", src: @src)
end
end
Expand All @@ -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 }
Expand All @@ -41,7 +41,7 @@ def initialize(name:)
@name = name
end

def template
def view_template
i(class: @name)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_single_component_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(size:)
@size = size
end

def template(&content)
def view_template(&content)
h1(class: "text-#{@size}", &content)
end
end
Expand All @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_single_component_string_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -25,7 +25,7 @@ def initialize(size:)
@size = size
end

def template(&content)
def view_template(&content)
h1(class: "text-#{@size}", &content)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/phlex/test_single_generic_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/phlex/test_single_lambda_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down
6 changes: 3 additions & 3 deletions test/phlex/test_single_polymorphic_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(src:)
@src = src
end

def template
def view_template
img(class: "image", src: @src)
end
end
Expand All @@ -24,7 +24,7 @@ class ProfileCard < Phlex::HTML
end
}

def template
def view_template
if avatar_slot?
div id: "avatar" do
render avatar_slot
Expand All @@ -41,7 +41,7 @@ def initialize(name:)
@name = name
end

def template
def view_template
i(class: @name)
end
end
Expand Down

0 comments on commit c109625

Please sign in to comment.