Skip to content

ActionView::Template#encode! cannot handle emacs style file-local variables #11951

Closed
tomyuk opened this Issue Aug 21, 2013 · 7 comments

6 participants

@tomyuk
tomyuk commented Aug 21, 2013

example:
Once you have written the beginning of the *.json.jbuilder files the following line, then will cause syntax error

# -*- coding: utf-8; mode: ruby; -*-
@pftg
pftg commented Aug 21, 2013

Does this feature request? If so, then better ask opinion on ruby on rails core group https://groups.google.com/forum/#!forum/rubyonrails-core or create a patch with new behaviour.

coding: utf-8; mode: ruby; should be comment. So you should use:

# -*- coding: utf-8; mode: ruby; -*-

or

# coding: utf-8; mode: ruby;

I'm not familiar with emacs, but in vim they should not conflict with syntax of the language

@senny
Ruby on Rails member
senny commented Aug 22, 2013

Actually I think we should consider this to be an issue. "Magic Comments" from Emacs work everywhere else so they should also work in jbuilder templates. For reference the error is:

ActionView::Template::Error: /my_app/app/views/api/websites/show.json.jbuilder:1: syntax error, unexpected *
...=JbuilderTemplate.new(self); -*-

when using the following legit magic comment:

# -*- coding: utf-8 -*-

/cc @guilleiguaran @carlosantoniodasilva

@tomyuk
tomyuk commented Aug 22, 2013

I think this is a issu.
I have reported the case of emacs is not just only in one case. jbuilder is a DSL of ruby. Therefore, Actionview must be treated properly as well as the ruby interpreter. So, I think this is a mistake in the implementation.

@guilleiguaran
Ruby on Rails member

This works fine in .erb templates?

@senny
Ruby on Rails member
senny commented Dec 1, 2013

@guilleiguaran I don't think erb is a good comparison as jbuilder is clearly a ruby DSL. However I just double checked with builder templates. And it fails too. I still consider this to be an issue both builder and jbuilder accept comments starting with # so why shouldn't I be able to place a comment like # -*- coding: utf-8 -*- in my file?

@tomyuk tomyuk added the stale label Apr 23, 2014
@rafaelfranca
Ruby on Rails 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 rails-bot closed this May 27, 2014
@rails-bot

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
Something went wrong with that request. Please try again.