Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaenous use of manifest and a magic comment #7455

Closed
Exoth opened this issue Aug 27, 2012 · 19 comments
Closed

Simultaenous use of manifest and a magic comment #7455

Exoth opened this issue Aug 27, 2012 · 19 comments

Comments

@Exoth
Copy link

Exoth commented Aug 27, 2012

Rails 3.2.8.

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.

@gaurish
Copy link
Contributor

gaurish commented Aug 31, 2012

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.

Correct?

@steveklabnik
Copy link
Member

That seems like it might be the issue, yes. I forget exactly how all this works, to be honest, but that sounds about right.

@gaurish
Copy link
Contributor

gaurish commented Aug 31, 2012

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 :)

@steveklabnik
Copy link
Member

Discussing this with @tenderlove, apparently there are bugs in jsc when you include Unicode in your javascript. Mountain Lion seems to fix them, but there may be dragons down this road.

@steveklabnik
Copy link
Member

Why are you including the magic comment, by the way? Rails should serve everything with a utf8 encoding by default.

@gaurish
Copy link
Contributor

gaurish commented Aug 31, 2012

That we will have to ask @Exoth. I was just trying to help fix a bug(if any)

btw, what is jsc?

[edit]
Nvm, found it but how is this relevant to rails? Do we use it to run tests? or something else?

@steveklabnik
Copy link
Member

Since Rails has the 'use whatever Javascript runtime' code in it, you may get intermittent failures due to environmental differences :/

@Exoth
Copy link
Author

Exoth commented Aug 31, 2012

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.

@steveklabnik
Copy link
Member

Ahh, yes, processing in plain ruby outside of Rails would make this happen. Just wondering; obviously, that should work somehow.

@parndt
Copy link
Contributor

parndt commented Dec 4, 2012

Is this really a Rails issue or a Sprockets issue? Is it still relevant?

@Exoth
Copy link
Author

Exoth commented Dec 4, 2012

The last time I checked the problem was still here.

@steveklabnik
Copy link
Member

It's part of Rails for 3.2, it's part of sprockets-rails for Rails 4.

@Exoth
Copy link
Author

Exoth commented Dec 4, 2012

Very good. Looking forward for the Rails 4 release.

@tgaff
Copy link

tgaff commented Feb 22, 2013

I've got the same problem. One workaround is to run ruby with -Ku to avoid needing the magic comment at all.

@gaurish
Copy link
Contributor

gaurish commented Apr 28, 2013

Ruby 2.0 has UTF-8 default encoding, which may make magic comments omissible & fix this issue.

@JonRowe
Copy link
Contributor

JonRowe commented May 18, 2013

@gaurish except that while Rails supports 1.9.3 that isn't an acceptable fix ;) has anyone made any progress on this? [triage]

@tgaff
Copy link

tgaff commented May 18, 2013

I used something like this temporarily: tgaff/sprockets@a098b35

@Exoth Exoth added the stale label Apr 23, 2014
@rafaelfranca
Copy link
Member

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

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.

@rails-bot
Copy link

This issue has been automatically closed because of inactivity.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants