Merge pull request #663 from alexpeattie/slim-redcarpet-fix

Fix for embedded Markdown in Slim w/ Redcarpet
This commit is contained in:
Ben Hollis 2012-11-07 22:01:33 -08:00
commit 434895be0c
2 changed files with 16 additions and 5 deletions

View file

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

View file

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