Class: Coradoc::Html::Drop::BlockDrop
- Inherits:
-
Base
- Object
- Liquid::Drop
- Base
- Coradoc::Html::Drop::BlockDrop
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
Instance Method Details
#content ⇒ Object
35
36
37
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 35
def content
content_to_liquid(@model.renderable_content)
end
|
#css_class ⇒ Object
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
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
55
56
57
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 55
def hr?
resolved_semantic_type == :horizontal_rule
end
|
#html_tag ⇒ Object
22
23
24
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 22
def html_tag
SEMANTIC_TAG_MAP[resolved_semantic_type] || 'div'
end
|
#language ⇒ Object
26
27
28
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 26
def language
@model.language || @model.metadata('language')
end
|
#raw? ⇒ Boolean
51
52
53
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 51
def raw?
resolved_semantic_type == :pass
end
|
#semantic_type ⇒ Object
18
19
20
|
# File 'lib/coradoc/html/drop/block_drop.rb', line 18
def semantic_type
resolved_semantic_type.to_s
end
|
#text ⇒ Object
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
|