Module: PDoc::Generators::Html::Helpers::BaseHelper

Included in:
Page, Website
Defined in:
lib/pdoc/generators/html/helpers.rb

Instance Method Summary collapse

Instance Method Details

#content_tag(tag_name, content, attributes = {}) ⇒ Object



6
7
8
# File 'lib/pdoc/generators/html/helpers.rb', line 6

def (tag_name, content, attributes = {})
  "<#{tag_name}#{attributes_to_html(attributes)}>#{content}</#{tag_name}>"
end

#htmlize(markdown) ⇒ Object



23
24
25
26
# File 'lib/pdoc/generators/html/helpers.rb', line 23

def htmlize(markdown)
  markdown = Website.syntax_highlighter.parse(markdown)
  Website.markdown_parser.new(markdown).to_html
end

#img_tag(filename, attributes = {}) ⇒ Object



10
11
12
13
# File 'lib/pdoc/generators/html/helpers.rb', line 10

def img_tag(filename, attributes = {})
  attributes.merge! :src => "#{path_prefix}images/#{filename}"
  tag(:img, attributes)
end

#inline_htmlize(markdown) ⇒ Object

Gah, what an ugly hack.



29
30
31
# File 'lib/pdoc/generators/html/helpers.rb', line 29

def inline_htmlize(markdown)
  htmlize(markdown).gsub(/^<p>/, '').gsub(/<\/p>$/, '')
end

#javascript_include_tag(*names) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/pdoc/generators/html/helpers.rb', line 33

def javascript_include_tag(*names)
  names.map do |name|
    attributes = {
      :src => "#{path_prefix}javascripts/#{name}.js",
      :type => "text/javascript",
      :charset => "utf-8"
    }
    (:script, "", attributes)
  end.join("\n")
end


19
20
21
# File 'lib/pdoc/generators/html/helpers.rb', line 19

def link_to(name, path, attributes={})
  (:a, name, attributes.merge(:href => path))
end


44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pdoc/generators/html/helpers.rb', line 44

def stylesheet_link_tag(*names)
  names.map do |name|
    attributes = {
      :href => "#{path_prefix}stylesheets/#{name}.css",
      :type => "text/css",
      :media => "screen, projection",
      :charset => "utf-8",
      :rel => "stylesheet"
    }
    tag(:link, attributes)
  end.join("\n")
end

#tag(tag_name, attributes = {}) ⇒ Object



15
16
17
# File 'lib/pdoc/generators/html/helpers.rb', line 15

def tag(tag_name, attributes = {})
  "<#{tag_name}#{attributes_to_html(attributes)} />"
end