Slide 37
Slide 37 text
Railsのturbo_frames_tag
ヘルパーのコードを見てみる
content_tag_string
メソッドが最終的にシンプルな文字列(HTML)を返す
# ActionView::Helpers::TagHelper::TagBuilder
def tag_string(name, content = nil, options, escape: true, &block)
# ブロック(=フレームで囲んだ内部のerb)があれば、内部で実行(yield)して文字列として返す
content = @view_context.capture(self, &block) if block
content_tag_string(name, content, options, escape)
end
def content_tag_string(name, content, options, escape = true)
# 属性="値" の形にoptionsを変換
tag_options = tag_options(options, escape) if options
if escape && content.present?
content = ERB::Util.unwrapped_html_escape(content)
end
"<#{name}#{tag_options}>#{PRE_CONTENT_STRINGS[name]}#{content}".html_safe
end
turbo_frame_tag(@todo) #=> ``