Skip to content

statevdev/rails-project-63

Repository files navigation

CI Status Hexlet-Checkout Status

HexletCode

This gem provides an easy-to-use interface for creating HTML forms.

Installation

Add this line to your Gemfile:

gem 'hexlet_code', git: 'https://github.com/statevdev/rails-project-63.git'

Then execute:

bundle install

Usage

To create a form, you need to pass in a data structure about its future fields, here is an example of such a structure:

User = Struct.new(:name, :job, keyword_init: true)
user = User.new(name: 'rob', job: 'hexlet')

The required form fields are passed through the block to the form_for method:

HexletCode.form_for user do |f|
  f.input :name
  f.input :job, as: :text
end

In the output we get:

# <form action="#" method="post">
#<input name="name" type="text" value="rob">
#<textarea name="job" cols="20" rows="40">hexlet</textarea>
# </form>

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published