diff --git a/lib/middleman.rb b/lib/middleman.rb index 417c61b2..a4c0ca1b 100755 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -73,6 +73,7 @@ module Middleman autoload :Sass, "middleman/renderers/sass" autoload :Slim, "middleman/renderers/slim" autoload :Markdown, "middleman/renderers/markdown" + autoload :ERb, "middleman/renderers/erb" autoload :CoffeeScript, "middleman/renderers/coffee_script" autoload :Liquid, "middleman/renderers/liquid" end diff --git a/lib/middleman/core_extensions/front_matter.rb b/lib/middleman/core_extensions/front_matter.rb index b11eb240..6c3a3d4a 100644 --- a/lib/middleman/core_extensions/front_matter.rb +++ b/lib/middleman/core_extensions/front_matter.rb @@ -101,6 +101,9 @@ module Middleman::CoreExtensions::FrontMatter class ERBTemplate < ::Tilt::ERBTemplate include Middleman::CoreExtensions::FrontMatter::YamlAware end + class ErubisTemplate < ::Tilt::ErubisTemplate + include Middleman::CoreExtensions::FrontMatter::YamlAware + end class LiquidTemplate < ::Tilt::LiquidTemplate include Middleman::CoreExtensions::FrontMatter::YamlAware diff --git a/lib/middleman/core_extensions/rendering.rb b/lib/middleman/core_extensions/rendering.rb index 94162213..b6ea97d4 100644 --- a/lib/middleman/core_extensions/rendering.rb +++ b/lib/middleman/core_extensions/rendering.rb @@ -11,6 +11,7 @@ module Middleman::CoreExtensions::Rendering app.register Middleman::Renderers::Haml app.register Middleman::Renderers::Sass app.register Middleman::Renderers::Markdown + app.register Middleman::Renderers::ERb app.register Middleman::Renderers::CoffeeScript app.register Middleman::Renderers::Liquid end diff --git a/lib/middleman/renderers/erb.rb b/lib/middleman/renderers/erb.rb new file mode 100644 index 00000000..236cf789 --- /dev/null +++ b/lib/middleman/renderers/erb.rb @@ -0,0 +1,34 @@ +require "tilt" + +module Middleman::Renderers::ERb + class << self + def registered(app) + app.extend ClassMethods + + app.set :erb_engine, :erb + + if !app.respond_to? :erb_engine_prefix + app.set :erb_engine_prefix, ::Tilt + end + + app.after_configuration do + engine = app.settings.erb_engine + + if engine.is_a? Symbol + engine = app.tilt_template_from_symbol(engine) + end + + ::Tilt.prefer(engine) + end + end + alias :included :registered + end + + module ClassMethods + def tilt_template_from_symbol(engine) + engine = engine.to_s + engine = engine == "erb" ? "ERB" : engine.camelize + settings.erb_engine_prefix.const_get("#{engine}Template") + end + end +end \ No newline at end of file