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

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

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

#calloutsObject



36
37
38
39
40
41
42
# File 'lib/coradoc/html/drop/block_drop.rb', line 36

def callouts
  return [] unless verbatim?

  @callouts ||= CoreModel::CalloutText.ordered(@model.callouts).map do |callout|
    { 'index' => callout.index, 'content' => Escape.escape_html(callout.content.to_s) }
  end
end

#callouts?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/coradoc/html/drop/block_drop.rb', line 44

def callouts?
  !callouts.empty?
end

#contentObject



24
25
26
# File 'lib/coradoc/html/drop/block_drop.rb', line 24

def content
  content_to_liquid(@model.renderable_content)
end

#css_classObject



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

def css_class
  cls = TagMapping.css_class_for(resolved_semantic_type)
  cls ? "block-#{semantic_type} #{cls}" : "block-#{semantic_type}"
end

#hidden?Boolean

Returns:

  • (Boolean)


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

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

#hr?Boolean

Returns:

  • (Boolean)


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

def hr?
  resolved_semantic_type == :horizontal_rule
end

#html_tagObject



11
12
13
# File 'lib/coradoc/html/drop/block_drop.rb', line 11

def html_tag
  TagMapping.tag_for(resolved_semantic_type)
end

#languageObject



15
16
17
# File 'lib/coradoc/html/drop/block_drop.rb', line 15

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

#raw?Boolean

Returns:

  • (Boolean)


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

def raw?
  resolved_semantic_type == :pass
end

#semantic_typeObject



7
8
9
# File 'lib/coradoc/html/drop/block_drop.rb', line 7

def semantic_type
  resolved_semantic_type.to_s
end

#textObject



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

def text
  if verbatim?
    Escape.escape_html(stripped_text)
  elsif resolved_semantic_type == :pass
    @model.flat_text.to_s
  end
end