Class: GeraBlog::RedcarpetDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/gerablog/redcarpet.rb

Overview

My Render class

Instance Method Summary collapse

Constructor Details

#initialize(lang, config) ⇒ RedcarpetDriver

Returns a new instance of RedcarpetDriver.



33
34
35
36
37
38
# File 'lib/gerablog/redcarpet.rb', line 33

def initialize(lang, config)
  @template = config['template']
  @blog = config['blog']
  @config = config
  @render = Redcarpet::Markdown.new(RedcarpetCustom.new(lang: lang))
end

Instance Method Details

#converted(post, content) ⇒ Object



40
41
42
43
# File 'lib/gerablog/redcarpet.rb', line 40

def converted(post, content)
  post[:converted] = @render.render(content.gsub(/^#/,'##'))
  post
end

#to_html(post, content, categories) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gerablog/redcarpet.rb', line 45

def to_html(post, content, categories)
  Tenjin::Engine.new.render(
    @template['post'],
    config: @config,
    post: converted(post, content),
    categories: categories,
    title: {
      title: post[:title],
      description: post[:description]
    }
  )
end