开发者

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

开发者 https://www.devze.com 2023-02-11 15:36 出处:网络
Is there any way to see view code converted to html other than starting p开发者_运维百科roject and view the page source? In Rails development environment, we can use code and see what it returns, but

Is there any way to see view code converted to html other than starting p开发者_运维百科roject 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?


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\" />"
0

精彩评论

暂无评论...
验证码 换一张
取 消