Class: Coradoc::Html::Drop::BlockDrop

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/html/drop/block_drop.rb

Constant Summary collapse

SEMANTIC_TAG_MAP =
{
  paragraph: 'p', source_code: 'pre', quote: 'blockquote',
  verse: 'blockquote', example: 'div', sidebar: 'aside',
  literal: 'pre', listing: 'pre', open: 'div',
  horizontal_rule: 'hr'
}.freeze
SEMANTIC_CLASS_MAP =
{
  example: 'example', sidebar: 'sidebar', literal: 'literal'
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#model

Instance Method Summary collapse

Methods inherited from Base

#id, #initialize, #template_type, #title, #to_liquid

Constructor Details

This class inherits a constructor from Coradoc::Html::Drop::Base

Instance Method Details

#contentObject



35
36
37
# File 'lib/coradoc/html/drop/block_drop.rb', line 35

def content
  content_to_liquid(@model.renderable_content)
end

#css_classObject



30
31
32
33
# File 'lib/coradoc/html/drop/block_drop.rb', line 30

def css_class
  cls = SEMANTIC_CLASS_MAP[resolved_semantic_type]
  cls ? "block-#{semantic_type} #{cls}" : "block-#{semantic_type}"
end

#hidden?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/coradoc/html/drop/block_drop.rb', line 47

def hidden?
  %i[comment reviewer].include?(resolved_semantic_type)
end

#hr?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/coradoc/html/drop/block_drop.rb', line 55

def hr?
  resolved_semantic_type == :horizontal_rule
end

#html_tagObject



22
23
24
# File 'lib/coradoc/html/drop/block_drop.rb', line 22

def html_tag
  SEMANTIC_TAG_MAP[resolved_semantic_type] || 'div'
end

#languageObject



26
27
28
# File 'lib/coradoc/html/drop/block_drop.rb', line 26

def language
  @model.language || @model.('language')
end

#raw?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/coradoc/html/drop/block_drop.rb', line 51

def raw?
  resolved_semantic_type == :pass
end

#semantic_typeObject



18
19
20
# File 'lib/coradoc/html/drop/block_drop.rb', line 18

def semantic_type
  resolved_semantic_type.to_s
end

#textObject



39
40
41
42
43
44
45
# File 'lib/coradoc/html/drop/block_drop.rb', line 39

def text
  if %i[source_code literal listing].include?(resolved_semantic_type)
    Escape.escape_html(@model.flat_text)
  elsif resolved_semantic_type == :pass
    @model.flat_text.to_s
  end
end