Module: ExpoTurbo::Rails::Frames::Helper

Includes:
ExpoTurbo::Rails::Format::Helper
Defined in:
lib/expo_turbo/rails/frames/helper.rb

Instance Method Summary collapse

Instance Method Details

#turbo_frame_tag(*ids, src: nil, target: nil, **attributes, &block) ⇒ Object

The standard turbo-rails helper. For an HTML render it is turbo-rails exactly, through super. For an Expo Turbo render the same tag is produced and then admitted: valid UTF-8 XML without declarations, DTDs, or processing instructions, a nonblank literal Frame id, and the configured components and style tokens. Validation never serializes the result, so preserved text keeps its authored bytes.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/expo_turbo/rails/frames/helper.rb', line 17

def turbo_frame_tag(*ids, src: nil, target: nil, **attributes, &block)
  return super unless expo_turbo_render?

  ids = expo_turbo_normalized_frame_ids(ids)
  literal_id = expo_turbo_literal_frame_id(ids)
  Frames.validate_id!(literal_id) if literal_id
  frame = super
  document = XmlFragments.parse_frame_fragment(frame.to_s)
  Frames.validate_id!(expo_turbo_rendered_frame_id(document))
  controller.send(:expo_turbo_validate_frame_fragment!, document)
  frame
rescue XmlFragments::ParseError
  raise TemplateError, "Expo Turbo Frame output must be well-formed UTF-8 XML without DTDs or processing instructions"
end