Permalink
Browse files

lib/jekyll/rendering.rb: Work around encoding issues on Ruby 1.9.

  • Loading branch information...
1 parent ddfced4 commit d4176388e0ead9c09b6307ac802cef96e8f60e24 @blackwinter blackwinter committed May 22, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/jekyll/rendering.rb
@@ -144,11 +144,22 @@ class Erb < Base
class << self; attr_accessor :renderer; end
- attr_reader :site, :page, :renderer
+ attr_reader :site, :page, :renderer, :encoding
def initialize(*args)
super
+ if ''.respond_to?(:force_encoding)
+ @encoding = site.respond_to?(:encoding) &&
+ site.encoding || Encoding.default_external
+
+ data.each_value { |val|
+ if val.respond_to?(:force_encoding) && !val.frozen?
+ val.force_encoding(encoding)
+ end
+ }
+ end
+
[Helpers, *info[:filters]].each { |mod| extend mod }
%w[site page paginator].each { |key|
@@ -179,7 +190,8 @@ def render(content = content, local_assigns = {}, *args)
end
def _render_erb(doc, binding, args = Rendering::ERB_OPTIONS)
- renderer.new(doc, *args).result(binding)
+ res = renderer.new(doc, *args).result(binding)
+ encoding ? res.force_encoding(encoding) : res
end
def _render(doc, binding, args = [])

0 comments on commit d417638

Please sign in to comment.