nonopolarity
nonopolarity

Reputation: 151264

on Rails, is there any way to output content besides the <%= %> tag?

it seems that on Rails or erb, the only way to output anything is by <%= %>

<% puts "hello" %> won't work, unlike PHP.

is there any other method at all?

Upvotes: 1

Views: 303

Answers (2)

nonopolarity
nonopolarity

Reputation: 151264

concat will do:

<% concat ("wah ha ha!") %>

Reference:
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001710

from the source code,

<% output_buffer << "hmm" %>

will work too and it is tested... but i think this is even lower level and should be avoided.

Upvotes: 2

James L
James L

Reputation: 16874

The conventional response object does exist under the covers, and you can call response.write(str). But a large part of the beauty of RoR is that this nuts and bolts stuff is abstracted away for you, and you don't have to do it.

Upvotes: 1

Related Questions