Yad Smood
Yad Smood

Reputation: 2932

Is there a way to modify the indentation style of Rails templates?

If a user really want to take the advantage of tab. Is there a way to set code indentation style of Rails permanently? It will be great if I could just edit some config file to achieve it.

For example, when I'm using scaffold "rails generate scaffold Articals name:string", the auto-generated code is 4-space-indented styled. So that I don't need to use the editor to convert them manually every time.

I'm not asking a programming or syntax question. Rails is not a language. This is all about settings and config. Or I can write a program to auto convert them in background(not a best practice).

If Rails really can't do it, will the team add it in future?

Upvotes: 3

Views: 1540

Answers (2)

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84363

Since the OP has updated the question to address modifying the scaffolding templates, and not just indentation styles, the following links might be a useful starting point.

You can also refer to Creating and Customizing Rails Generators & Templates for additional guidance on how to modify core templates.

Upvotes: 2

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

No, there is no setting. Most generators run off of templates, and those templates are themselves written by developers with mostly 2 spacing for tabs.

You asked: "Or I can write a program to auto convert them in background."

Yes! in fact, you could do so in Ruby... Something that would look at all new files in git and replace four and two spaces with tabs. Probably only if the line begins with four and/or 2 spaces, but still.

Upvotes: 1

Related Questions