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

(erb) .rb generator files should be renamed to .rb.erb #23847

Closed
kares opened this issue Feb 24, 2016 · 8 comments
Closed

(erb) .rb generator files should be renamed to .rb.erb #23847

kares opened this issue Feb 24, 2016 · 8 comments
Labels

Comments

@kares
Copy link
Contributor

kares commented Feb 24, 2016

assuming they do not contain valid ruby code they should not be named .rb
this would not only be cleaner but allow tools such as Warbler pre-compiling .rb files without hustle

each sub-gem seems to have these under lib/rails/generators e.g. with active_record :

https://github.com/rails/rails/tree/master/activerecord/lib/rails/generators/active_record/model/templates

lib/rails/generators/active_record/model/templates/model.rb -> .../model.rb.erb
lib/rails/generators/active_record/model/templates/module.rb -> .../module.rb.erb

proposing to rename those and update the related files, would this be acceptable by the team?

@rafaelfranca
Copy link
Member

I don't see any problem of using the tt extension (which is the one
recommend by Thor) but first I want to understand better the problem. Which
problem does these files cause? Would not the same problem happen with erb?
Does it happen because people try to compile the entire lib folder?

On Wed, Feb 24, 2016, 09:01 Chashmeet Singh notifications@github.com
wrote:

.erb files are for layouts mate
.rb for ruby
I guess its a bad idea renaming them to .rb.erb


Reply to this email directly or view it on GitHub
#23847 (comment).

@kares
Copy link
Contributor Author

kares commented Feb 24, 2016

@chashmeetsingh thanks, but I thought that a file that doesn't load by Ruby "should not" be named .rb

@rafaelfranca assume you have a Rails app and you'd like to pre-compile your .rb files (including gems). a simplest way to do this is to walk all of the gemspec.lib **/*.rb files.
users of such scenarios (with Warbler under JRuby) bump into an issue with some .rb files not being "really" Ruby and thus require careful excludes ... all of these files are seen from Rails' gems (at least reports only mentioned them so far) and it seems that they might not need to have the .rb extension

e.g. lib/rails/generators/active_record/model/templates/model.rb :

<% module_namespacing do -%>
module <%= class_path.map(&:camelize).join('::') %>
  def self.table_name_prefix
    '<%= namespaced? ? namespaced_class_path.join('_') : class_path.join('_') %>_'
  end
end
<% end -%>

have mostly used .rb.erb extension for such files, but I do not insist on having that extension

@kares kares changed the title (erb) .rb templates should be renamed to .rb.erb (erb) .rb generator files should be renamed to .rb.erb Feb 24, 2016
@rafaelfranca
Copy link
Member

I see. I'm fine with renaming them.

@kares
Copy link
Contributor Author

kares commented Feb 24, 2016

OK thanks, will setup a PR - this affects several gems. is it acceptable if I use the .rb.erb name then?

@rafaelfranca
Copy link
Member

.rb.tt is our preferred way.

@kares
Copy link
Contributor Author

kares commented Feb 24, 2016

OK

@rails-bot
Copy link

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 5-0-stable branch 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 5-0-stable branch 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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants