middleman/middleman-core/lib/middleman-core/renderers/slim.rb

48 lines
1 KiB
Ruby
Raw Normal View History

# Load gem
require 'slim'
2014-02-19 03:30:29 +01:00
module SafeTemplate
def render(*)
super.html_safe
end
end
class Slim::Template
include SafeTemplate
def precompiled_preamble(locals)
"__in_slim_template = true\n" << super
end
end
module Middleman
module Renderers
# Slim renderer
class Slim < ::Middleman::Extension
# Setup extension
def initialize(_app, _options={}, &_block)
super
# Setup Slim options to work with partials
::Slim::Engine.set_default_options(
buffer: '@_out_buf',
use_html_safe: true,
generator: ::Temple::Generators::RailsOutputBuffer,
disable_escape: true
)
end
2013-12-28 19:14:15 +01:00
def after_configuration
context_hack = {
context: app.template_context_class.new(app)
}
2013-04-14 18:24:48 +02:00
::Slim::Embedded::SassEngine.disable_option_validator!
%w(sass scss markdown).each do |engine|
::Slim::Embedded.default_options[engine.to_sym] = context_hack
end
end
end
end
end