Module: YARD::Templates::Helpers::HtmlHelper
- Defined in:
- lib/yard/templates/helpers/html_helper.rb
Overview
Monkey into YARD’s HtmlHelper module to add common methods we want available in HTML templates.
Instance Method Summary collapse
-
#htmlify_cucumber_line(text, markup = nil, strip: true) ⇒ String
Like #htmlify_cucumber_text but operates on single lines via #h for ‘:none`.
-
#htmlify_cucumber_text(text, markup = nil, strip: true) ⇒ String
Wrapper for HTML-ifying text from Cucumber features and scenarios that takes into account the ‘yard-cucumber.markup` config value.
-
#htmlify_with_newlines(text) ⇒ String
Original HTML-ification method, that is now referred to as ‘:none` markup.
Instance Method Details
#htmlify_cucumber_line(text, markup = nil, strip: true) ⇒ String
Like #htmlify_cucumber_text but operates on single lines via #h for ‘:none`.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/yard/templates/helpers/html_helper.rb', line 131 def htmlify_cucumber_line(text, markup=nil, strip: true) # Resolve the `markup` {Symbol} markup = resolve_cucumber_markup markup # Switch off to the appropriate method. case markup when :none # Do what it was before: call {#h} h(text) when :default # Do whatever the rest of YARD is doing. htmlify_line(strip ? text.strip : text) else htmlify_line(strip ? text.strip : text, markup) end end |
#htmlify_cucumber_text(text, markup = nil, strip: true) ⇒ String
Wrapper for HTML-ifying text from Cucumber features and scenarios that takes into account the ‘yard-cucumber.markup` config value.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/yard/templates/helpers/html_helper.rb', line 97 def htmlify_cucumber_text(text, markup=nil, strip: true) # Resolve the `markup` {Symbol} markup = resolve_cucumber_markup markup # Switch off to the appropriate method. case markup when :none # Do what it was before: call {#htmlify_with_newlines}, escapes entities # and replaces "\n" with `<br/>` tags. htmlify_with_newlines(text) when :default # Do whatever the rest of YARD is doing. htmlify(strip ? text.strip : text) else htmlify(strip ? text.strip : text, markup) end end |
#htmlify_with_newlines(text) ⇒ String
2019.01.10 nrser This method used to be duplicated in ‘lib/templates/default/`…
but de-duplicated it to here after creating this file for #htmlify_cucumber_text.
Original HTML-ification method, that is now referred to as ‘:none` markup. Escapes HTML entities and replaces newlines with `<br/>`.
32 33 34 |
# File 'lib/yard/templates/helpers/html_helper.rb', line 32 def htmlify_with_newlines(text) text.split("\n").collect {|c| h(c).gsub(/\s/,' ') }.join("<br/>") end |