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

37 lines
1.1 KiB
Ruby
Raw Normal View History

2011-12-31 23:28:17 +01:00
# ERb renderer
module Middleman
module Renderers
module ERb
# Setup extension
class << self
# once registered
def registered(app)
# Setup a default ERb engine
2012-10-14 04:54:55 +02:00
app.config.define_setting :erb_engine, :erb, 'The engine to use for rendering ERb templates'
app.config.define_setting :erb_engine_prefix, ::Tilt, 'The parent module for ERb template engines'
app.before_configuration do
template_extensions :erb => :html
end
# After config
app.after_configuration do
# Find the user's prefered engine
# Convert symbols to classes
2012-10-14 04:54:55 +02:00
if config[:erb_engine].is_a? Symbol
engine = engine.to_s
engine = engine == "erb" ? "ERB" : engine.camelize
2012-10-14 04:54:55 +02:00
config[:erb_engine] = config[:erb_engine_prefix].const_get("#{engine}Template")
end
# Tell Tilt to use the preferred engine
2012-10-14 04:54:55 +02:00
::Tilt.prefer(config[:erb_engine])
end
end
alias :included :registered
2011-10-27 18:24:48 +02:00
end
end
end
end