Class: MarkdownUI::InputTag
- Inherits:
-
Object
- Object
- MarkdownUI::InputTag
- Defined in:
- lib/markdown-ui/tag/input_tag.rb
Instance Method Summary collapse
-
#initialize(content, klass = nil, _id = nil, data = nil) ⇒ InputTag
constructor
A new instance of InputTag.
- #render ⇒ Object
Constructor Details
#initialize(content, klass = nil, _id = nil, data = nil) ⇒ InputTag
Returns a new instance of InputTag.
3 4 5 6 7 8 |
# File 'lib/markdown-ui/tag/input_tag.rb', line 3 def initialize(content, klass = nil, _id = nil, data = nil) @klass = klass @content = content @data = data @id = _id end |
Instance Method Details
#render ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/markdown-ui/tag/input_tag.rb', line 10 def render content = if @content " type=\'#{@content.strip.downcase}\'" else nil end klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil? _id = if @id " placeholder=\'#{@id.capitalize}\'" end data = if @data _data, attribute, value = @data.split(':') " data-#{attribute}=\'#{value}\'" else nil end "<input#{content}#{_id}#{klass}#{data} />" end |