Cleanup renderers
This commit is contained in:
parent
2297100d9e
commit
874ebc13c9
|
@ -1,20 +1,23 @@
|
|||
# Require gem
|
||||
require "haml"
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
||||
# Haml Renderer
|
||||
module Middleman::Renderers::Haml
|
||||
module Haml
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
# Once registered
|
||||
def registered(app)
|
||||
# Add haml helpers to context
|
||||
app.send :include, ::Haml::Helpers
|
||||
# Require gem
|
||||
require "haml"
|
||||
|
||||
app.before_configuration do
|
||||
template_extensions :haml => :html
|
||||
end
|
||||
|
||||
# Add haml helpers to context
|
||||
app.send :include, ::Haml::Helpers
|
||||
|
||||
# Setup haml helper paths
|
||||
app.ready do
|
||||
init_haml_helpers
|
||||
|
@ -23,3 +26,5 @@ module Middleman::Renderers::Haml
|
|||
alias :included :registered
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,8 @@
|
|||
module Middleman
|
||||
module Renderers
|
||||
|
||||
# Liquid Renderer
|
||||
module Middleman::Renderers::Liquid
|
||||
module Liquid
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
@ -9,7 +12,6 @@ module Middleman::Renderers::Liquid
|
|||
# Liquid is not included in the default gems,
|
||||
# but we'll support it if available.
|
||||
begin
|
||||
|
||||
# Require Gem
|
||||
require "liquid"
|
||||
|
||||
|
@ -19,7 +21,7 @@ module Middleman::Renderers::Liquid
|
|||
|
||||
# After config, setup liquid partial paths
|
||||
app.after_configuration do
|
||||
Liquid::Template.file_system = Liquid::LocalFileSystem.new(source_dir)
|
||||
::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(source_dir)
|
||||
|
||||
# Convert data object into a hash for liquid
|
||||
sitemap.provides_metadata %r{\.liquid$} do |path|
|
||||
|
@ -33,3 +35,6 @@ module Middleman::Renderers::Liquid
|
|||
alias :included :registered
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,20 +1,16 @@
|
|||
module Middleman
|
||||
module Renderers
|
||||
|
||||
# Markdown renderer
|
||||
module Middleman::Renderers::Markdown
|
||||
module Markdown
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
||||
# Once registered
|
||||
def registered(app)
|
||||
# Require redcarpet gem
|
||||
require "redcarpet"
|
||||
|
||||
# Forcably disable Redcarpet1 support.
|
||||
# Tilt defaults to this if available, but the compat
|
||||
# layer disables extensions.
|
||||
Object.send(:remove_const, :RedcarpetCompat) if defined? ::RedcarpetCompat
|
||||
|
||||
# Set our preference for a markdown engine
|
||||
# TODO: Find a JRuby-compatible version
|
||||
app.set :markdown_engine, :redcarpet
|
||||
app.set :markdown_engine_prefix, ::Tilt
|
||||
|
||||
|
@ -33,14 +29,23 @@ module Middleman::Renderers::Markdown
|
|||
unless markdown_engine.nil?
|
||||
|
||||
# Map symbols to classes
|
||||
if markdown_engine.is_a? Symbol
|
||||
markdown_engine_klass = if markdown_engine.is_a? Symbol
|
||||
engine = markdown_engine.to_s
|
||||
engine = engine == "rdiscount" ? "RDiscount" : engine.camelize
|
||||
markdown_engine = markdown_engine_prefix.const_get("#{engine}Template")
|
||||
markdown_engine_prefix.const_get("#{engine}Template")
|
||||
else
|
||||
markdown_engine_prefix
|
||||
end
|
||||
|
||||
# Tell tilt to use that engine
|
||||
::Tilt.prefer(markdown_engine)
|
||||
::Tilt.prefer(markdown_engine_klass)
|
||||
|
||||
if markdown_engine == :redcarpet
|
||||
# Forcably disable Redcarpet1 support.
|
||||
# Tilt defaults to this if available, but the compat
|
||||
# layer disables extensions.
|
||||
Object.send(:remove_const, :RedcarpetCompat) if defined? ::RedcarpetCompat
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -48,3 +53,5 @@ module Middleman::Renderers::Markdown
|
|||
alias :included :registered
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,19 +1,23 @@
|
|||
# Pull in gems
|
||||
require "sprockets"
|
||||
require "sprockets-sass"
|
||||
require "sass"
|
||||
|
||||
# Stick with Compass' asset functions
|
||||
Sprockets::Sass.add_sass_functions = false
|
||||
module Middleman
|
||||
module Renderers
|
||||
|
||||
# Sass renderer
|
||||
module Middleman::Renderers::Sass
|
||||
module Sass
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
||||
# Once registered
|
||||
def registered(app)
|
||||
require "sass"
|
||||
|
||||
# Stick with Compass' asset functions
|
||||
::Sprockets::Sass.add_sass_functions = false
|
||||
|
||||
# Default sass options
|
||||
app.set :sass, {}
|
||||
|
||||
|
@ -21,6 +25,20 @@ module Middleman::Renderers::Sass
|
|||
template_extensions :scss => :css,
|
||||
:sass => :css
|
||||
end
|
||||
|
||||
# Tell Sprockets to use our custom Sass template
|
||||
::Sprockets.register_engine ".sass", SassPlusCSSFilenameTemplate
|
||||
|
||||
# Tell Tilt to use it as well (for inline sass blocks)
|
||||
::Tilt.register 'sass', SassPlusCSSFilenameTemplate
|
||||
::Tilt.prefer(SassPlusCSSFilenameTemplate)
|
||||
|
||||
# Tell Sprockets to use our custom Scss template
|
||||
::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
|
||||
|
||||
# Tell Tilt to use it as well (for inline scss blocks)
|
||||
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
|
||||
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
|
||||
end
|
||||
|
||||
alias :included :registered
|
||||
|
@ -55,13 +73,6 @@ module Middleman::Renderers::Sass
|
|||
end
|
||||
end
|
||||
|
||||
# Tell Sprockets to use our custom Sass template
|
||||
::Sprockets.register_engine ".sass", SassPlusCSSFilenameTemplate
|
||||
|
||||
# Tell Tilt to use it as well (for inline sass blocks)
|
||||
::Tilt.register 'sass', SassPlusCSSFilenameTemplate
|
||||
::Tilt.prefer(SassPlusCSSFilenameTemplate)
|
||||
|
||||
# SCSS version of the above template
|
||||
class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate
|
||||
|
||||
|
@ -72,10 +83,6 @@ module Middleman::Renderers::Sass
|
|||
end
|
||||
end
|
||||
|
||||
# Tell Sprockets to use our custom Scss template
|
||||
::Sprockets.register_engine ".scss", ScssPlusCSSFilenameTemplate
|
||||
|
||||
# Tell Tilt to use it as well (for inline scss blocks)
|
||||
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
|
||||
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,8 @@
|
|||
module Middleman
|
||||
module Renderers
|
||||
|
||||
# Slim renderer
|
||||
module Middleman::Renderers::Slim
|
||||
module Slim
|
||||
|
||||
# Setup extension
|
||||
class << self
|
||||
|
@ -17,7 +20,10 @@ module Middleman::Renderers::Slim
|
|||
end
|
||||
|
||||
# Setup Slim options to work with partials
|
||||
Slim::Engine.set_default_options(:buffer => '@_out_buf', :generator => Temple::Generators::StringBuffer) if defined?(Slim)
|
||||
::Slim::Engine.set_default_options(
|
||||
:buffer => '@_out_buf',
|
||||
:generator => ::Temple::Generators::StringBuffer
|
||||
)
|
||||
rescue LoadError
|
||||
end
|
||||
end
|
||||
|
@ -25,3 +31,5 @@ module Middleman::Renderers::Slim
|
|||
alias :included :registered
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue