Module: InfoHelpers
- Included in:
- DocRenderer::Base
- Defined in:
- lib/paperwork/tasks/middleman_template/lib/info_helpers.rb
Overview
helpers for info fields in documents
Instance Method Summary collapse
- #footer_text ⇒ Object
- #navbar? ⇒ Boolean
- #navbar_brand ⇒ Object
- #navbar_links ⇒ Object
- #page_info(**options) ⇒ Object
- #paperwork? ⇒ Boolean
- #relative_link(stringifyable, current_path = current_page.path) ⇒ Object
- #text_for(**options) ⇒ Object
- #toc? ⇒ Boolean
Instance Method Details
#footer_text ⇒ Object
60 61 62 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 60 def data.paperwork. if paperwork? end |
#navbar? ⇒ Boolean
42 43 44 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 42 def paperwork? && data.paperwork.respond_to?(:navbar) end |
#navbar_brand ⇒ Object
56 57 58 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 56 def data.paperwork..brand if end |
#navbar_links ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 46 def nav = data.paperwork..links if nav ||= {} mapped = {} nav.each do |name, link| mapped[name] = relative_link(link) end mapped end |
#page_info(**options) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 15 def page_info(**) content_for :page_infos do .keys.map do |name| partial("layouts/info", locals: { name: name, value: [name] }) end.join end end |
#paperwork? ⇒ Boolean
38 39 40 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 38 def paperwork? data.respond_to?(:paperwork) end |
#relative_link(stringifyable, current_path = current_page.path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 23 def relative_link(stringifyable, current_path = current_page.path) relative = String.new dots = current_path.split(/[\/\\]/).size - 1 dots.times{ relative += "../" } # This has been some nasty part to debug... # keep these comments for debugging session yet to come # puts "##################################" # puts "current_page.path: #{current_page.path}" # puts "stringifyable: #{stringifyable.to_s}" # puts "dots: #{dots}" # puts "relative link: #{relative + stringifyable.to_s}" # puts "##################################" relative + stringifyable.to_s end |
#text_for(**options) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 7 def text_for(**) .keys.map do |key| content_for key do [key].to_s end end end |
#toc? ⇒ Boolean
64 65 66 67 68 |
# File 'lib/paperwork/tasks/middleman_template/lib/info_helpers.rb', line 64 def toc? !data.paperwork.config.nil? && !data.paperwork.config.toc.nil? && data.paperwork.config.toc end |