2011-12-31 23:28:17 +01:00
|
|
|
# ERb renderer
|
2012-04-14 22:51:02 +02:00
|
|
|
module Middleman
|
|
|
|
module Renderers
|
|
|
|
module ERb
|
|
|
|
# Setup extension
|
|
|
|
class << self
|
2012-08-14 00:39:06 +02:00
|
|
|
|
2012-04-14 22:51:02 +02:00
|
|
|
# once registered
|
|
|
|
def registered(app)
|
|
|
|
# After config
|
|
|
|
app.after_configuration do
|
2014-02-19 03:30:29 +01:00
|
|
|
::Tilt.prefer(Template, :erb)
|
2012-04-14 22:51:02 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
alias :included :registered
|
2011-10-27 18:24:48 +02:00
|
|
|
end
|
2014-02-19 03:30:29 +01:00
|
|
|
|
|
|
|
class Template < ::Tilt::ErubisTemplate
|
|
|
|
##
|
|
|
|
# In preamble we need a flag `__in_erb_template` and SafeBuffer for padrino apps.
|
|
|
|
#
|
|
|
|
def precompiled_preamble(locals)
|
|
|
|
original = super
|
|
|
|
"__in_erb_template = true\n" << original
|
|
|
|
#.rpartition("\n").first << "#{@outvar} = _buf = ActiveSupport::SafeBuffer.new\n"
|
|
|
|
end
|
|
|
|
end
|
2011-10-27 18:24:48 +02:00
|
|
|
end
|
|
|
|
end
|
2012-08-14 00:39:06 +02:00
|
|
|
end
|