Class: Mook::Renderer
- Inherits:
-
Object
- Object
- Mook::Renderer
- Defined in:
- lib/mook/renderer.rb
Constant Summary collapse
- MARKDOWN_OPTIONS =
{ :strikethrough => true, :fenced_code_blocks => true, :space_after_headers => true, :superscript => true, :autolink => true }
- HTML_OPTIONS =
{ }
Instance Method Summary collapse
-
#initialize(site) ⇒ Renderer
constructor
A new instance of Renderer.
- #render!(page) ⇒ Object
Constructor Details
#initialize(site) ⇒ Renderer
Returns a new instance of Renderer.
14 15 16 |
# File 'lib/mook/renderer.rb', line 14 def initialize(site) @site = site end |
Instance Method Details
#render!(page) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mook/renderer.rb', line 18 def render!(page) renderer = HtmlRenderer.new(HTML_OPTIONS) md = Redcarpet::Markdown.new(renderer, MARKDOWN_OPTIONS) page.content = md.render(page.markdown) page.toc = md.render(renderer.toc) template = ERB.new(File.read(File.join("templates", page.template))) model = Model.new(@site, page) page.output = renderer.postprocess(template.result(model.binding)) end |