Put template rendering in a jail

This commit is contained in:
Thomas Reynolds 2014-01-01 21:19:05 -08:00
parent 9798f152ca
commit 305d2f99ed
17 changed files with 233 additions and 169 deletions

View file

@ -12,6 +12,10 @@
class Middleman::Extensions::Gzip < ::Middleman::Extension
option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.'
class NumberHelpers
include ::Padrino::Helpers::NumberHelpers
end
def initialize(app, options_hash={})
super
@ -57,11 +61,11 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
if output_filename
total_savings += (old_size - new_size)
size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger'
builder.say_status :gzip, "#{output_filename} (#{app.number_to_human_size((old_size - new_size).abs)} #{size_change_word})"
builder.say_status :gzip, "#{output_filename} (#{NumberHelpers.new.number_to_human_size((old_size - new_size).abs)} #{size_change_word})"
end
end
builder.say_status :gzip, "Total gzip savings: #{app.number_to_human_size(total_savings)}", :blue
builder.say_status :gzip, "Total gzip savings: #{NumberHelpers.new.number_to_human_size(total_savings)}", :blue
I18n.locale = old_locale
end