Module: Odin::Forms
- Defined in:
- lib/odin/forms.rb,
lib/odin/forms/css.rb,
lib/odin/forms/types.rb,
lib/odin/forms/units.rb,
lib/odin/forms/parser.rb,
lib/odin/forms/renderer.rb,
lib/odin/forms/accessibility.rb
Overview
ODIN Forms — parse and render declarative form definitions.
Defined Under Namespace
Modules: Accessibility, Css, ElementType, Units
Classes: FormElement, FormPage, OdinForm, PageTemplate, Parser, Renderer
Class Method Summary
collapse
Class Method Details
.contrast_ratio(fg, bg) ⇒ Object
.from_pixels(px, unit) ⇒ Object
38
39
40
|
# File 'lib/odin/forms.rb', line 38
def from_pixels(px, unit)
Units.from_pixels(px, unit)
end
|
.generate_field_id(element_name, page_index) ⇒ Object
42
43
44
|
# File 'lib/odin/forms.rb', line 42
def generate_field_id(element_name, page_index)
Accessibility.generate_field_id(element_name, page_index)
end
|
.generate_print_css ⇒ Object
.meets_contrast_aa(fg, bg, font_size) ⇒ Object
Parse ODIN forms text into a typed OdinForm.
15
16
17
18
|
# File 'lib/odin/forms.rb', line 15
def parse_form(text)
text = text.encode("UTF-8") if text.is_a?(String) && text.encoding != Encoding::UTF_8
Parser.new.parse(text)
end
|
Render an OdinForm to a complete HTML string. data is an optional OdinDocument bound to field values; options accepts :className.
22
23
24
|
# File 'lib/odin/forms.rb', line 22
def render_form(form, data = nil, options = nil)
Renderer.new.render(form, data, options)
end
|
.to_pixels(value, unit) ⇒ Object
34
35
36
|
# File 'lib/odin/forms.rb', line 34
def to_pixels(value, unit)
Units.to_pixels(value, unit)
end
|