Class: TextFieldTag
- Inherits:
-
LiquidumTag
- Object
- LiquidumTag
- TextFieldTag
- Defined in:
- lib/scribo/liquid/tags/text_field_tag.rb
Overview
Add a text-field, either specifying everything manually or using a model object on the form
Basic usage:
{%text_field name:"name" value:"Pencil"%}
Advanced usage:
{%text_field name%}
This last usage requires a model on the form
Direct Known Subclasses
DateFieldTag, EmailFieldTag, HiddenFieldTag, NumberFieldTag, PasswordFieldTag, SearchFieldTag, TelephoneFieldTag, TimeFieldTag, UrlFieldTag
Instance Attribute Summary collapse
-
#field_type ⇒ Object
Returns the value of attribute field_type.
Instance Method Summary collapse
-
#initialize(tag, args, tokens) ⇒ TextFieldTag
constructor
A new instance of TextFieldTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag, args, tokens) ⇒ TextFieldTag
Returns a new instance of TextFieldTag.
16 17 18 19 |
# File 'lib/scribo/liquid/tags/text_field_tag.rb', line 16 def initialize(tag, args, tokens) super @field_type = 'text' end |
Instance Attribute Details
#field_type ⇒ Object
Returns the value of attribute field_type.
14 15 16 |
# File 'lib/scribo/liquid/tags/text_field_tag.rb', line 14 def field_type @field_type end |
Instance Method Details
#render(context) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scribo/liquid/tags/text_field_tag.rb', line 21 def render(context) super result = %[<input] + attr_str(:name, arg(:name), input(:name, argv1)) + attr_str(:id, arg(:id), input(:id, argv1)) + attr_str(:value, arg(:value), input(:value, argv1)) result += attrs_str(reject: %[name value id]) result += %[ type="#{field_type}"/>] result end |