Reputation: 10151
Looking for simple html form generator gem. I have to generate an html form, but its not like ActionView::Form, just generator without any args like:
form.create do |f|
f.text :comment
f.name :name
end
that generates
<input type="text" name="comment" />
<input type="text" name="name" />
Any gist, or parser/generator or library?
Upvotes: 0
Views: 1452
Reputation: 168091
Yes. The dom gem that I have developed does exactly what you want. You can generate HTML strings like this:
require "dom"
["foo".dom(:span, class: "bold"), "bar"].dom(:div).dom(:body).dom(:html)
# => "<html><body><div><span class=\"bold\">foo</span>bar</div></body></html>"
Upvotes: 0
Reputation: 3265
Builder is great. It works well, and seems to function just about like what something I would write. The interface is clean and easy. I used it last week for a similar project.
Upvotes: 2