1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/renderers/markdown.rb

35 lines
907 B
Ruby
Raw Normal View History

module Middleman::Renderers::Markdown
class << self
def registered(app)
2011-11-17 22:56:55 -05:00
app.send :include, InstanceMethods
2011-11-19 17:54:03 -05:00
begin
require "maruku"
app.set :markdown_engine, :maruku
rescue LoadError
app.set :markdown_engine, nil
end
2011-11-17 22:56:55 -05:00
app.set :markdown_engine_prefix, ::Tilt
app.after_configuration do
2011-11-17 22:56:55 -05:00
unless markdown_engine.nil?
if markdown_engine.is_a? Symbol
markdown_engine = markdown_tilt_template_from_symbol(markdown_engine)
2011-11-10 18:56:04 -05:00
end
2011-11-17 22:56:55 -05:00
::Tilt.prefer(markdown_engine)
2011-11-10 18:56:04 -05:00
end
end
end
alias :included :registered
end
2011-11-17 22:56:55 -05:00
module InstanceMethods
2011-11-10 18:56:04 -05:00
def markdown_tilt_template_from_symbol(engine)
engine = engine.to_s
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
2011-11-17 22:56:55 -05:00
markdown_engine_prefix.const_get("#{engine}Template")
end
end
end