Skip to content

Commit

Permalink
Bit more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Nov 3, 2023
1 parent 9e5db9d commit 2a159dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/lifeform/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def template(&block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComple
def auto_render_fields = html_map(self.class.fields) { |k, _v| render(field(k)) }

def render(field_object)
field_object.render_in(self)
field_object.render_in(helpers || self)
end
end
end
8 changes: 8 additions & 0 deletions lib/lifeform/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def attribute_segment(attr, value)
"#{attr}=#{value.to_s.encode(xml: :attr)}"
end

def attrs(callback)
attrs_string = attributes_from_options(callback.() || {})

attrs_string = " #{attrs_string}" unless attrs_string.blank?

attrs_string
end

# Below is verbatim copied over from Bridgetown
# TODO: extract both out to a shared gem

Expand Down
12 changes: 0 additions & 12 deletions lib/lifeform/renderable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ module Lifeform
module Renderable
include Lifeform::Helpers

def attrs(callback)
attrs_string = attributes_from_options(callback.() || {})

attrs_string = " #{attrs_string}" unless attrs_string.blank?

attrs_string
end

def tag(tag, content, **options)
"<#{tag}#{attrs -> { options }}>#{text -> { content }}</#{tag}>"
end

def render_in(view_context, &block)
@_view_context = view_context
template(&block).to_s.strip
Expand Down

0 comments on commit 2a159dc

Please sign in to comment.