Module: Context
- Defined in:
- lib/extensions/utils/block.rb
Overview
Helper methods handling whether to output inline content or a block. Will read the attributes of the current macro and output a HTML string that is either inline or a block (float-right).
Class Method Summary collapse
-
.format(attributes, target, pattern, label) ⇒ String
The raw HTML to be included in the target document.
Class Method Details
.format(attributes, target, pattern, label) ⇒ String
Returns the raw HTML to be included in the target document.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/extensions/utils/block.rb', line 12 def self.format(attributes, target, pattern, label) block = false unless attributes.key? 'block' if target[0] == "\:" block = true target[0] = '' end url = "#{pattern}/#{target}" html = if block if pattern == 'unknown' "<div style=\"float:right;padding-left:0.1em;\"><span class=\"label label-#{label}\" data-toggle=\"tooltip\" title=\"Missing config\">#{target}</span></div>" else "<div style=\"float:right;padding-left:0.1em;\"><a href=\"#{url}\"><span class=\"label label-#{label} task\">#{target}</span></a></div>" end elsif attributes[:version] url = "search.html?q=Version+#{target}" "<div style=\"float:right;padding-left:0.1em;\"><a href=\"#{url}\" class=\"btn btn-primary btn-sm active\" role=\"button\" aria-pressed=\"true\">Version <span class=\"badge\">#{target}</span></a></div>" else if pattern == 'unknown' "<span class=\"label label-#{label}\" data-toggle=\"tooltip\" title=\"Missing config\">#{target}</span>" else "<a href=\"#{url}\"><span class=\"label label-#{label}\">#{target}</span></a>" end end html end |