public Method

TextHelper.concat(string, binding)

The preferred method of outputting text in your views is to use the <%= "text" %> eRuby syntax. The regular puts and print methods do not operate as expected in an eRuby code block. If you absolutely must output text within a non-output code block (i.e., <% %>), you can use the concat method.

Examples

<%
    concat "hello", binding
    # is the equivalent of <%= "hello" %>

    if (logged_in == true):
      concat "Logged in!", binding
    else
      concat link_to('login', :action => login), binding
    end
    # will either display "Logged in!" or a login link
%>

Source Code

# File action_view/helpers/text_helper.rb, line 28
def concat(string, binding)
  eval(ActionView::Base.erb_variable, binding) << string
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.