Skip to content

Instantly share code, notes, and snippets.

@leemour
Created April 4, 2013 11:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemour/5309759 to your computer and use it in GitHub Desktop.
Save leemour/5309759 to your computer and use it in GitHub Desktop.
Making Haml force UTF-8 by fixing Tilt
#=> 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