rubyprince
rubyprince

Reputation: 17793

A way to convert view commands to its corresponding html(like irb or ruby script/console)

Is there any way to see view code converted to html other than starting project and view the page source? In Rails development environment, we can use code and see what it returns, but it would have been nice if we were able to do something like this.

<< @user = User.all.map { |user| [user.name, user.id] }
=> [["Patrick", 1], ["Greg", 2]]
<< select_tag "user", @user, {}, :tab_index => "5"
=> "<select id=\"user\" name=\"user\" tab_index=\"5\"><option value=\"1\">Patrick</option>
<option value=\"2\">Greg</option>"

Is this possible?

Upvotes: 0

Views: 59

Answers (1)

alltom
alltom

Reputation: 3252

On Rails 3, you can access these helpers via helper.

$ rails console
>> helper.select_tag "user"
=> "<select id=\"user\" name=\"user\"></select>"
>> helper.submit_tag "goodbye"
=> "<input name=\"commit\" type=\"submit\" value=\"goodbye\" />"

Upvotes: 4

Related Questions