Class: Coradoc::Html::Drop::DefinitionItemDrop
- Inherits:
-
Base
- Object
- Liquid::Drop
- Base
- Coradoc::Html::Drop::DefinitionItemDrop
show all
- Defined in:
- lib/coradoc/html/drop/definition_item_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
Instance Method Details
#definitions ⇒ Object
27
28
29
30
31
|
# File 'lib/coradoc/html/drop/definition_item_drop.rb', line 27
def definitions
return [] unless @model.definitions
@model.definitions.map { |d| content_to_liquid(d) }
end
|
#nested ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/coradoc/html/drop/definition_item_drop.rb', line 33
def nested
nested_model = @model.nested
return nil unless nested_model.is_a?(CoreModel::DefinitionList) &&
nested_model.items&.any?
DropFactory.create(nested_model)
end
|
#term ⇒ Object
7
8
9
|
# File 'lib/coradoc/html/drop/definition_item_drop.rb', line 7
def term
Escape.escape_html(stripped_term)
end
|
#term_id ⇒ Object
22
23
24
25
|
# File 'lib/coradoc/html/drop/definition_item_drop.rb', line 22
def term_id
match = term_text.match(/\A\[\[([^\]]+)\]\]/)
match&.[](1)
end
|
#terms ⇒ Object
All terms on this <dt>, escaped and id-stripped. Multi-term
<dt>'s (AsciiDoc term1::\nterm2::) carry multiple entries;
templates iterate this collection to emit one <dt> per term.
Falls back to [term] for legacy callers that only set the
singular term accessor.
16
17
18
19
20
|
# File 'lib/coradoc/html/drop/definition_item_drop.rb', line 16
def terms
raw = @model.terms
collection = raw.nil? || raw.empty? ? [@model.term.to_s] : raw.map(&:to_s)
collection.map { |t| Escape.escape_html(strip_term_id(t)) }
end
|