2011-08-31 15:22:45 -04:00
|
|
|
require "tilt"
|
|
|
|
|
2011-07-10 16:41:53 -04:00
|
|
|
module Middleman::Renderers::Markdown
|
|
|
|
class << self
|
|
|
|
def registered(app)
|
2011-08-31 15:22:45 -04:00
|
|
|
app.extend ClassMethods
|
|
|
|
|
|
|
|
app.set :markdown_engine, :maruku
|
|
|
|
|
|
|
|
if !app.respond_to? :markdown_engine_prefix
|
2011-08-31 16:15:59 -04:00
|
|
|
app.set :markdown_engine_prefix, ::Tilt
|
2011-08-31 15:22:45 -04:00
|
|
|
end
|
|
|
|
|
2011-08-04 22:30:58 -04:00
|
|
|
app.after_configuration do
|
2011-08-31 15:22:45 -04:00
|
|
|
engine = app.settings.markdown_engine
|
|
|
|
|
|
|
|
if engine.is_a? Symbol
|
|
|
|
engine = app.tilt_template_from_symbol(engine)
|
|
|
|
end
|
|
|
|
|
2011-08-31 16:15:59 -04:00
|
|
|
::Tilt.prefer(engine)
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|
|
|
|
end
|
2011-07-10 16:41:53 -04:00
|
|
|
alias :included :registered
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|
2011-08-31 15:22:45 -04:00
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
def tilt_template_from_symbol(engine)
|
|
|
|
engine = engine.to_s
|
|
|
|
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
|
|
|
settings.markdown_engine_prefix.const_get("#{engine}Template")
|
|
|
|
end
|
|
|
|
end
|
2011-06-27 16:10:09 -04:00
|
|
|
end
|