Created
April 4, 2013 11:51
-
-
Save leemour/5309759 to your computer and use it in GitHub Desktop.
Making Haml force UTF-8 by fixing Tilt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=> apps.rb | |
## | |
# Add your before load hooks here | |
# | |
Padrino.before_load do | |
# Encoding.default_internal = nil | |
# Encoding.default_external = 'UTF-8' | |
end | |
# this makes haml to treat templates as properly encoded (respect Encoding.default_external) | |
module Tilt | |
class HamlTemplate | |
def prepare | |
@data.force_encoding Encoding.default_external | |
options = @options.merge(:filename => eval_file, :line => line) | |
@engine = ::Haml::Engine.new(data, options) | |
end | |
end | |
class CoffeeScriptTemplate | |
def prepare | |
@data.force_encoding Encoding.default_external | |
if !options.key?(:bare) and !options.key?(:no_wrap) | |
options[:bare] = self.class.default_bare | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment