2009-09-28 22:43:08 -04:00
|
|
|
begin
|
|
|
|
require 'maruku'
|
|
|
|
rescue LoadError
|
|
|
|
puts "Maruku not available. Install it with: gem install maruku"
|
|
|
|
end
|
|
|
|
|
|
|
|
module Middleman
|
|
|
|
module Maruku
|
2009-09-29 13:10:47 -04:00
|
|
|
def self.included(base)
|
|
|
|
base.supported_formats << "maruku"
|
|
|
|
end
|
|
|
|
|
2009-09-28 22:43:08 -04:00
|
|
|
def render_path(path)
|
|
|
|
if template_exists?(path, :maruku)
|
|
|
|
maruku path.to_sym
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def maruku(template, options={}, locals={})
|
|
|
|
render :maruku, template, options, locals
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def render_maruku(data, options, locals, &block)
|
|
|
|
maruku_src = render_erb(data, options, locals, &block)
|
|
|
|
instance = ::Maruku.new(maruku_src, options)
|
|
|
|
if block_given?
|
|
|
|
# render layout
|
|
|
|
instance.to_html_document
|
|
|
|
else
|
|
|
|
# render template
|
|
|
|
instance.to_html
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Base
|
2009-09-29 13:10:47 -04:00
|
|
|
include Middleman::Maruku
|
2009-09-28 22:43:08 -04:00
|
|
|
end
|
|
|
|
end
|