module ScribeDown::Renderer

Public Class Methods

add(file_name, options={}) click to toggle source
# File lib/generate/renderer.rb, line 38
def self.add(file_name, options={})
  options[:binding] = binding
  Res.read_file(file_name, options)
end
content() click to toggle source
# File lib/generate/renderer.rb, line 19
def self.content
  rendered_sections = Array.new
  @@sections.each do |section|
    rendered_sections.push render_section(section)
  end
  rendered_sections.join "\n\n"
end
head_tags() click to toggle source
# File lib/generate/renderer.rb, line 11
def self.head_tags
  rendered = Array.new
  @@settings[:styles].each do |style|
    rendered.push(stylesheet_tag style)
  end
  rendered.join "\n\n"
end
image_tag(url, options={}) click to toggle source
# File lib/generate/helpers.rb, line 14
def self.image_tag(url, options={})
  extras = options.map {|k,v| "#{k}=\"#{v}\"" }.join ' '
  "<img src=\"#{url}\" #{extras}/>"
end
render_section(section) click to toggle source
# File lib/generate/renderer.rb, line 27
def self.render_section(section)
  if @@templates.has_key? section.container
    template = @@templates[section.container]
  else
    template = Res.read_file(section.container, format: :plain)
    @@templates[section.container] = template
  end
  content = Res.read_file(section.path, format: section.format.to_sym, binding: binding)
  Res.erb_contents(template, binding)
end
stylesheet_tag(file_name) click to toggle source
# File lib/generate/helpers.rb, line 10
def self.stylesheet_tag(file_name)
  "<style>\n" + Res.read_file(file_name) + "\n</style>"
end
to_html(sections, settings) click to toggle source
# File lib/generate/renderer.rb, line 43
def self.to_html(sections, settings)
  @@settings = settings
  @@sections = sections
  @@templates = Hash.new
  title ||= settings[:title]
  return Res.read_file(settings[:base], binding: binding)
end
to_pdf(html_content) click to toggle source
# File lib/generate/renderer.rb, line 51
def self.to_pdf(html_content)
  PDFKit.new(html_content).to_pdf
end