Module: Piggly::Reporter::HtmlDsl
- Included in:
- Compiler::CoverageReport, Base
- Defined in:
- lib/piggly/reporter/html_dsl.rb
Overview
Markup DSL
Constant Summary collapse
- HTML_REPLACE =
{ "&" => "&", '"' => """, ">" => ">", "<" => "<" }
- HTML_PATTERN =
/[&"<>]/
Instance Method Summary collapse
Instance Method Details
#e(string) ⇒ Object
48 49 50 |
# File 'lib/piggly/reporter/html_dsl.rb', line 48 def e(string) string.fast_xs end |
#html(output = "") ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/piggly/reporter/html_dsl.rb', line 13 def html(output = "") begin @htmltag_output, htmltag_output = output, @htmltag_output # @todo: doctype yield ensure # restore @htmltag_output = htmltag_output end end |
#tag(name, content = nil, attributes = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/piggly/reporter/html_dsl.rb', line 24 def tag(name, content = nil, attributes = {}) if content.is_a?(Hash) and attributes.empty? content, attributes = nil, content end attributes = attributes.inject("") do |string, pair| k, v = pair string << %[ #{k}="#{v}"] end if content.nil? if block_given? @htmltag_output << "<#{name}#{attributes}>" yield @htmltag_output << "</#{name}>" else @htmltag_output << "<#{name}#{attributes}/>" end else @htmltag_output << "<#{name}#{attributes}>#{content.to_s}</#{name}>" end end |