Class: Live::View
Overview
Represents a single division of content on the page an provides helpers for rendering the content.
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#append!(element) ⇒ Object
Append to the content of the client-side element by appending the specified element.
-
#prepend!(element) ⇒ Object
Prepend to the content of the client-side element by appending the specified element.
-
#render(builder) ⇒ Object
Render the element.
-
#replace! ⇒ Object
Replace the content of the client-side element by rendering this view.
- #to_html ⇒ Object
Methods inherited from Element
#bind, #close, #forward, #handle, #initialize, #rpc
Constructor Details
This class inherits a constructor from Live::Element
Instance Method Details
#append!(element) ⇒ Object
Append to the content of the client-side element by appending the specified element.
36 37 38 |
# File 'lib/live/view.rb', line 36 def append!(element) rpc(:append, [@id, element.to_html]) end |
#prepend!(element) ⇒ Object
Prepend to the content of the client-side element by appending the specified element.
42 43 44 |
# File 'lib/live/view.rb', line 42 def prepend!(element) rpc(:prepend, [@id, element.to_html]) end |
#render(builder) ⇒ Object
Render the element.
48 49 |
# File 'lib/live/view.rb', line 48 def render(builder) end |
#replace! ⇒ Object
Replace the content of the client-side element by rendering this view.
30 31 32 |
# File 'lib/live/view.rb', line 30 def replace! rpc(:replace, [@id, self.to_html]) end |
#to_html ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/live/view.rb', line 52 def to_html Trenni::Builder.fragment do |builder| builder.tag :div, id: @id, class: 'live', data: @data do render(builder) end end end |