millisami
millisami

Reputation: 10151

Is there any ruby library to generate html form?

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

Answers (2)

sawa
sawa

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

Ryanmt
Ryanmt

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.

http://builder.rubyforge.org/

Upvotes: 2

Related Questions