Module: TurboRspec::Helpers
- Defined in:
- lib/turbo_rspec/helpers.rb
Instance Method Summary collapse
- #turbo_frame_html(id:, content: nil) ⇒ Object
- #turbo_stream_html(action:, target: nil, targets: nil, content: nil) ⇒ Object
Instance Method Details
#turbo_frame_html(id:, content: nil) ⇒ Object
13 14 15 |
# File 'lib/turbo_rspec/helpers.rb', line 13 def turbo_frame_html(id:, content: nil) "<turbo-frame id=\"#{id}\">#{content}</turbo-frame>" end |
#turbo_stream_html(action:, target: nil, targets: nil, content: nil) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/turbo_rspec/helpers.rb', line 5 def turbo_stream_html(action:, target: nil, targets: nil, content: nil) attrs = "action=\"#{action}\"" attrs += " target=\"#{target}\"" if target attrs += " targets=\"#{targets}\"" if targets inner = content ? "<template>#{content}</template>" : "<template></template>" "<turbo-stream #{attrs}>#{inner}</turbo-stream>" end |