Class: MarkdownUI::ItemTag

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown-ui/tag/item_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, klass = nil, link = nil) ⇒ ItemTag

Returns a new instance of ItemTag.



3
4
5
6
7
# File 'lib/markdown-ui/tag/item_tag.rb', line 3

def initialize(content, klass = nil, link = nil)
  @klass = klass
  @content = content
  @link = link
end

Instance Method Details

#renderObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/markdown-ui/tag/item_tag.rb', line 9

def render
  content, @data = @content.split(';')
  klass = MarkdownUI::KlassUtil.new(@klass).klass if @klass
  link = " href=\'#{@link.strip}\'" if @link

  data = if @data
    _data, attribute, value = @data.split(':')
    " data-#{attribute}=\'#{value}\'"
  else
    nil
  end

  "<a#{klass}#{data}#{link}>#{content}</a>"
end