Integrating Action View Helpers
Helpers without a block
def response
plain t("my.locale")
# ...
plain link_to "Show", post_path(@post)
# ...
plain my_own_view_helper_method
# ...
plain any_method_returning_a_string
endHelpers yielding a block
def response
# ...
plain do # <-- add this
form_with url: "/some_path" do |f|
matestack_to_s do # <-- add this, which converst following block to a string
plain f.text_field :foo # <-- call plain here again
br
div class: "some-input-wrapper" do
plain f.text_field :bar
end
br
plain f.submit
end
end
end
# ...
plain do
link_to root_path do
matestack_to_s do
div class: "some-link-wrapper" do
plain "foo from block"
end
end
end
end
# ...
# Code below will not work!
plain link_to root_path do
matestack_to_s do
div class: "some-link-wrapper" do
plain "foo from block"
end
end
end
endLast updated
Was this helpful?