Fix for embedded Markdown in Slim w/ Redcarpet

This commit is contained in:
Alex Peattie 2012-11-07 11:30:24 -08:00 committed by Thomas Reynolds
parent 4b7411b08a
commit 816bca9643
2 changed files with 16 additions and 5 deletions

View file

@ -5,6 +5,14 @@ module Middleman
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate::Redcarpet2
def initialize(*args, &block)
super
if @options.has_key?(:context)
@context = @options[:context]
end
end
# Overwrite built-in Tilt version.
# Don't overload :renderer option with smartypants
# Support renderer-level options
@ -32,9 +40,11 @@ module Middleman
renderer.new(render_options)
end
def evaluate(scope, locals, &block)
def evaluate(context, locals, &block)
@context ||= context
if @engine.renderer.respond_to? :middleman_app=
@engine.renderer.middleman_app = scope
@engine.renderer.middleman_app = @context
end
super
end

View file

@ -23,11 +23,12 @@ module Middleman
)
app.after_configuration do
sass_context_hack = {
context_hack = {
:context => self
}
::Slim::EmbeddedEngine.default_options[:sass] = sass_context_hack
::Slim::EmbeddedEngine.default_options[:scss] = sass_context_hack
%w(sass scss markdown).each do |engine|
::Slim::EmbeddedEngine.default_options[engine.to_sym] = context_hack
end
end
end