add element matcher comment
parent
b3c4c46616
commit
cdf1299c27
|
@ -8,14 +8,20 @@ require "./form/button"
|
||||||
require "./form/select_list"
|
require "./form/select_list"
|
||||||
require "./utils/element_matcher"
|
require "./utils/element_matcher"
|
||||||
|
|
||||||
|
# THis class represents the form tag of html.
|
||||||
class MechanizeCr::Form
|
class MechanizeCr::Form
|
||||||
include MechanizeCr::ElementMatcher
|
include MechanizeCr::ElementMatcher
|
||||||
|
|
||||||
getter node : Node | Lexbor::Node
|
getter node : Node | Lexbor::Node
|
||||||
|
# returns an array of `MechanizeCr::FormContent::Field` in the form.
|
||||||
getter fields : Array(FormContent::Field)
|
getter fields : Array(FormContent::Field)
|
||||||
|
# returns an array of input tags whose type is checkbox in the form.
|
||||||
getter checkboxes : Array(FormContent::CheckBox)
|
getter checkboxes : Array(FormContent::CheckBox)
|
||||||
|
# returns an array of input tags whose type is radio in the form.
|
||||||
getter radiobuttons : Array(FormContent::RadioButton)
|
getter radiobuttons : Array(FormContent::RadioButton)
|
||||||
|
# returns an array of input tags whose type is select in the form.
|
||||||
getter selectboxes : Array(FormContent::MultiSelectList)
|
getter selectboxes : Array(FormContent::MultiSelectList)
|
||||||
|
# returns an array of button tags and input tag whose type is button,submit,reset,image.
|
||||||
getter buttons : Array(FormContent::Button)
|
getter buttons : Array(FormContent::Button)
|
||||||
getter enctype : String
|
getter enctype : String
|
||||||
getter method : String
|
getter method : String
|
||||||
|
|
|
@ -6,11 +6,26 @@ module MechanizeCr::ElementMatcher
|
||||||
# Examples
|
# Examples
|
||||||
# ```
|
# ```
|
||||||
# # if you specify String like "foo", it searches form which name is "foo".
|
# # if you specify String like "foo", it searches form which name is "foo".
|
||||||
# # like <{{ singular.id }} name="foo"></form>
|
{% if ["form", "button"].includes?("#{singular.id}") %}
|
||||||
|
# # like <{{ singular.id }} name="foo"></{{ singular.id }}>
|
||||||
|
{% elsif "#{singular.id}" == "field" %}
|
||||||
|
# # like <input name="foo"></input>
|
||||||
|
{% elsif "#{singular.id}" == "radiobutton" %}
|
||||||
|
# # like <input type="radio" name="foo"></input>
|
||||||
|
{% else %}
|
||||||
|
# # like <input type="{{ singular.id }}" name="foo"></input>
|
||||||
|
{% end %}
|
||||||
# page.{{ plural.id }}_with("foo")
|
# page.{{ plural.id }}_with("foo")
|
||||||
#
|
|
||||||
# # you can also specify tag's attribute and its' value by NamedTuple or Hash(String, String).
|
# # you can also specify tag's attribute and its' value by NamedTuple or Hash(String, String).
|
||||||
# ex) <{{ singular.id }} class="foo"></form>
|
{% if ["form", "button"].includes?("#{singular.id}") %}
|
||||||
|
# # ex) <{{ singular.id }} class="foo"></{{ singular.id }}>
|
||||||
|
{% elsif "#{singular.id}" == "field" %}
|
||||||
|
# # ex) <input class="foo"></input>
|
||||||
|
{% elsif "#{singular.id}" == "radiobutton" %}
|
||||||
|
# # ex) <input type="radio" class="foo"></input>
|
||||||
|
{% else %}
|
||||||
|
# # ex) <input type="{{ singular.id }}" class="foo"></input>
|
||||||
|
{% end %}
|
||||||
# page.{{ plural.id }}_with("class" => "foo")
|
# page.{{ plural.id }}_with("class" => "foo")
|
||||||
# page.{{ plural.id }}_with(class: "foo")
|
# page.{{ plural.id }}_with(class: "foo")
|
||||||
# ```
|
# ```
|
||||||
|
|
Loading…
Reference in New Issue