Skip to content

Commit

Permalink
Update dependency on XRB and use new markup interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 28, 2024
1 parent 7391d7e commit 6883ce8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 9 additions & 3 deletions lib/live/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,17 @@ def render(builder)
builder.text(self.class.name)
end

def append_markup(output)
build_markup(::XRB::Builder.new(output))
end

def build_markup(builder)
render(builder)
end

# @returns [Object] The generated HTML.
def to_html
XRB::Builder.fragment do |builder|
render(builder)
end
XRB::Builder.fragment(&self.method(:build_markup))
end

# Convenience method for rendering the view as a string.
Expand Down
8 changes: 3 additions & 5 deletions lib/live/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ module Live
# Represents a single division of content on the page an provides helpers for rendering the content.
class View < Element
# @returns [Object] The generated HTML.
def to_html
XRB::Builder.fragment do |builder|
builder.inline_tag :div, id: @id, class: "live", data: @data do
render(builder)
end
def build_markup(builder)
builder.inline_tag :div, id: @id, class: "live", data: @data do
render(builder)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion live.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Gem::Specification.new do |spec|

spec.add_dependency "async-websocket", "~> 0.27"
spec.add_dependency "protocol-websocket", "~> 0.19"
spec.add_dependency "xrb"
spec.add_dependency "xrb", "~> 0.10"
end

0 comments on commit 6883ce8

Please sign in to comment.