You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the latest version of Tilt (1.3.6) you should be able to override the encoding like this:
Tilt.new(path,:default_encoding=>'utf-8')
We're aiming for merging in #175 soon. See the documentation in that pull request for how it will work in the future.
(I'm closing this now since it's been a while. Please re-open this if you need more help for with a workaround for current Tilt. Chime in on #175 if you have concerns about the upcoming encoding support.)
I use Tilt to handle my erb template which contain some chinese characters, But it was wrong:
Encoding::CompatibilityError in Servicdev::NodesController#show
incompatible character encodings: ASCII-8BIT and UTF-8
my ruby code is:
path = Rails.root.join('templates', "test.erb").to_s template = Tilt.new path template.render
and the test.erb's content is:
<%# 中文注释 %> <tag name="测试" />
I found the template.data.encoding is incorrect (ASCII-8BIT), So I can solve the problem by change the ruby code to:
path = Rails.root.join('templates', "test.erb").to_s template = Tilt.new path template.instance_variable_set(:@default_encoding, 'utf-8') template.render
But is that correct? will have any side effects? I'm not sure. I think this is a Tilt's bug
The text was updated successfully, but these errors were encountered: