Skip to content

Commit

Permalink
Use block instead of block_given? for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Jul 1, 2023
1 parent 8875d0a commit 2a5c5c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/phlex/elements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def #{method_name}(**attributes, &block)
target = @_context.target
if attributes.length > 0 # with attributes
if block_given? # with content block
if block # with content block
target << "<#{tag}" << (Phlex::ATTRIBUTE_CACHE[respond_to?(:process_attributes) ? (attributes.hash + self.class.hash) : attributes.hash] || __attributes__(**attributes)) << ">"
yield_content(&block)
target << "</#{tag}>"
else # without content block
target << "<#{tag}" << (Phlex::ATTRIBUTE_CACHE[respond_to?(:process_attributes) ? (attributes.hash + self.class.hash) : attributes.hash] || __attributes__(**attributes)) << "></#{tag}>"
end
else # without attributes
if block_given? # with content block
if block # with content block
target << "<#{tag}>"
yield_content(&block)
target << "</#{tag}>"
Expand Down

0 comments on commit 2a5c5c5

Please sign in to comment.