Class: Blogue::KramdownTemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/blogue/kramdown_template_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ KramdownTemplateHandler

Returns a new instance of KramdownTemplateHandler.



5
6
7
# File 'lib/blogue/kramdown_template_handler.rb', line 5

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#preprocessor=(value) ⇒ Object (writeonly)

Sets the attribute preprocessor

Parameters:

  • value

    the value to set the attribute preprocessor to.



3
4
5
# File 'lib/blogue/kramdown_template_handler.rb', line 3

def preprocessor=(value)
  @preprocessor = value
end

Instance Method Details

#call(template) ⇒ Object



9
10
11
12
13
# File 'lib/blogue/kramdown_template_handler.rb', line 9

def call(template)
  @preprocessor.call(template) if @preprocessor.respond_to?(:call)
  mdown = ActionView::Template.registered_template_handler(:erb).(template)
  "Kramdown::Document.new(begin;#{mdown};end, #{@options.inspect}).to_html"
end