Class: Metanorma::Html::Drops::FormulaDrop
- Inherits:
-
BlockElementDrop
- Object
- Liquid::Drop
- BlockElementDrop
- Metanorma::Html::Drops::FormulaDrop
- Defined in:
- lib/metanorma/html/drops/formula_drop.rb
Instance Attribute Summary collapse
-
#number_html ⇒ Object
readonly
Returns the value of attribute number_html.
-
#stem_html ⇒ Object
readonly
Returns the value of attribute stem_html.
-
#where_html ⇒ Object
readonly
Returns the value of attribute where_html.
-
#where_label ⇒ Object
readonly
Returns the value of attribute where_label.
Attributes inherited from BlockElementDrop
#content_html, #css_class, #id, #label_html, #type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id: nil, stem_html: nil, where_html: nil, where_label: nil, number_html: nil, css_class: nil) ⇒ FormulaDrop
constructor
A new instance of FormulaDrop.
Constructor Details
#initialize(id: nil, stem_html: nil, where_html: nil, where_label: nil, number_html: nil, css_class: nil) ⇒ FormulaDrop
Returns a new instance of FormulaDrop.
9 10 11 12 13 14 15 16 17 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 9 def initialize(id: nil, stem_html: nil, where_html: nil, where_label: nil, number_html: nil, css_class: nil) @id = id @stem_html = stem_html @where_html = where_html @where_label = where_label @number_html = number_html @css_class = css_class end |
Instance Attribute Details
#number_html ⇒ Object (readonly)
Returns the value of attribute number_html.
7 8 9 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 7 def number_html @number_html end |
#stem_html ⇒ Object (readonly)
Returns the value of attribute stem_html.
7 8 9 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 7 def stem_html @stem_html end |
#where_html ⇒ Object (readonly)
Returns the value of attribute where_html.
7 8 9 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 7 def where_html @where_html end |
#where_label ⇒ Object (readonly)
Returns the value of attribute where_label.
7 8 9 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 7 def where_label @where_label end |
Class Method Details
.from_model(formula, renderer:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/metanorma/html/drops/formula_drop.rb', line 19 def self.from_model(formula, renderer:) id = renderer.safe_attr(formula, :id) stem_html = if formula.stem renderer.render_stem_content(formula.stem) end where_parts = [] if formula.key if formula.key.dl where_parts << (renderer.render_definition_list(formula.key.dl) || "") end formula.key.p&.each do |para| where_parts << (renderer.render_paragraph(para) || "") end end formula.dl&.then do |dl| where_parts << (renderer.render_definition_list(dl) || "") end formula.p&.each do |para| next if renderer.safe_attr(para, :keep_with_next) where_parts << (renderer.render_paragraph(para) || "") end where_html = where_parts.join needs_where_label = !formula.key.nil? || !formula.dl.nil? || has_where_paragraph?(formula, renderer) name_el = renderer.safe_attr(formula, :fmt_name) || renderer.safe_attr( formula, :name ) number_html = if name_el renderer.render_inline_element(name_el) end new( id: id, stem_html: stem_html, where_html: where_html, where_label: needs_where_label, number_html: number_html, css_class: "formula", ) end |