You can clone with
HTTPS or Subversion.
I've got a .js.erb file where I need to use both manifest and a magic comment, and I would assume that this should work:
<%# encoding: utf-8 %>
//= require some_stuff
or at least this should work:
<%# encoding: utf-8 %>//= require some_stuff
as erb processing has to be done before js processing resulting in js getting simple
//= require some_stuff
But for some strange reason manifest directives don't work and are just included as text. Putting manifest definitions the first and encoding the second enables manifest but disables encoding.
If I can understant correctly,
After ERB processing is done, the magic comment still remain on the top of the file. While doing the js prepossing, sprockets expects the //= require style comments to start from very first line. if it find something else like blank lines or some other code, it stops looking for any //= require in that file & just renders the complete file as text without any further modifications.
That seems like it might be the issue, yes. I forget exactly how all this works, to be honest, but that sounds about right.
Well, we can add a simple conditional in sprockets code for magic comment. It would check is first line is a magic comment specifying the encoding, if yes then would scan rest of the file for any //= require until blank lines are encountered.
Let me know if this is the correct approach to fix or there is a better way. I will try to write patch over the weekend :)
Why are you including the magic comment, by the way? Rails should serve everything with a utf8 encoding by default.
That we will have to ask @Exoth. I was just trying to help fix a bug(if any)
btw, what is jsc?
Nvm, found it but how is this relevant to rails? Do we use it to run tests? or something else?
Later in this fils is a 'render' of a file with some special symbols. Until I have the magic comment, it gives me an error of incompatibility with ASCII.
Ahh, yes, processing in plain ruby outside of Rails would make this happen. Just wondering; obviously, that should work somehow.
Is this really a Rails issue or a Sprockets issue? Is it still relevant?
The last time I checked the problem was still here.
It's part of Rails for 3.2, it's part of sprockets-rails for Rails 4.
Very good. Looking forward for the Rails 4 release.
I've got the same problem. One workaround is to run ruby with -Ku to avoid needing the magic comment at all.
Ruby 2.0 has UTF-8 default encoding, which may make magic comments omissible & fix this issue.
@gaurish except that while Rails supports 1.9.3 that isn't an acceptable fix ;) has anyone made any progress on this? [triage]
I used something like this temporarily: tgaff/sprockets@a098b35
This issue has been automatically marked as stale because it has not been commented on for at least
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.
This issue has been automatically closed because of inactivity.