Skip to content

Commit

Permalink
Revise TextHelper#concat code example [ci-skip]
Browse files Browse the repository at this point in the history
This simplifies the code example, and avoids putting `%>` _inside_ an
ERB tag, which confuses the syntax highlighter.
  • Loading branch information
jonathanhefner committed Nov 24, 2023
1 parent ca5c27e commit 4bfa69a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions actionview/lib/action_view/helpers/text_helper.rb
Expand Up @@ -46,17 +46,20 @@ module TextHelper
# output text within a non-output code block (i.e., <tt><% %></tt>), you
# can use the +concat+ method.
#
# <% concat "hello" %> is equivalent to <%= "hello" %>
#
# <%
# concat "hello"
# # is the equivalent of <%= "hello" %>
#
# if logged_in
# concat "Logged in!"
# else
# concat link_to('login', action: :login)
# end
# # will either display "Logged in!" or a login link
# unless signed_in?
# concat link_to("Sign In", action: :sign_in)
# end
# %>
#
# is equivalent to
#
# <% unless signed_in? %>
# <%= link_to "Sign In", action: :sign_in %>
# <% end %>
#
def concat(string)
output_buffer << string
end
Expand Down

0 comments on commit 4bfa69a

Please sign in to comment.