Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 55 lines (38 sloc) 1.788 kb
7fa300f @jeremyevans Initial WIP
authored
1 = Forme
2
3 Forme is a HTML forms library for ruby with the following goals:
4
5 1) Have no external dependencies
6 2) Have a simple API
7 3) Support forms both with and without related objects
8375d6b @jeremyevans Massive refactoring, completely new API
authored
8 4) Allow compiling down to different types of output, by using
7fa300f @jeremyevans Initial WIP
authored
9 an intermediate abstract syntax tree, similar to Sequel
10
8375d6b @jeremyevans Massive refactoring, completely new API
authored
11 = Basic Usage
7fa300f @jeremyevans Initial WIP
authored
12
8375d6b @jeremyevans Massive refactoring, completely new API
authored
13 Without an object, is a simple form builder:
14
15 f = Forme::Form.new
16 f.open(:action=>'/foo', :method=>:post) # '<form action="/foo" method="post">
17 f.input(:textarea, :value=>'foo', :name=>'bar') # '<textarea name="bar">foo</textarea>'
18 f.input(:text, :value=>'foo', :name=>'bar') # '<input name="bar" type="text" value="foo"/>'
19 f.close # '</form>'
20
21 With an object, calls +forme_input+ on the obj with the form, field, and options, which
22 should return a <tt>Forme::Input</tt> instance.
23
24 f = Forme::Form.new(obj)
25 # obj.forme_input(f, :field, opts)
26 # => Forme::Input.new(f, :text, :name=>'obj[field]', :id=>'obj_field', :value=>'foo')
27 f.input(:field) # '<input id="obj_field" name="obj[field]" type="text" value="foo"/>'
28
889b27b @jeremyevans Handle case where object does not respond to forme_input
authored
29 If the object doesn't respond to +forme_input+, it falls back to creating text fields
30 with the name and id set to the field name and the value set by calling the given method
31 on the object.
32
33 f = Forme::Form.new([:foo])
34 f.input(:first) # '<input id="first" name="first" type="text" value="foo"/>'
35
8375d6b @jeremyevans Massive refactoring, completely new API
authored
36 = Main Classes
37
38 <tt>Forme::Form</tt> :: main object
39 <tt>Forme::Input</tt> :: high level abstract tag
40 <tt>Forme::Tag</tt> :: low level abstract tag
41 <tt>Forme::Formatter</tt> :: takes input, returns tag
42 <tt>Forme::Serializer</tt> :: tags tag, returns string
43
44 = Other Similar Projects
45
46 All of these have external dependencies:
47
48 1) Rails built-in helpers
49 2) Formtastic
50 3) padrino-helpers
7fa300f @jeremyevans Initial WIP
authored
51
52 = Author
53
54 Jeremy Evans <code@jeremyevans.net>
Something went wrong with that request. Please try again.