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