Site icon Michaël Rigart

Rails new template file extensions

For some of you that don’t know this yet (don’t be ashamed of yourself, I only heard about it a a few months back), Rails 2 recommends a new file extension for your template file. At this point, everyone was using template extensions like:

To unify the template files, the Rails developers have come with a clever solution: changing the template extensions so that they math up and tell you in what format they are. By doing this, your new template extensions should look like this:

You are probably thinking: “everything looks alike now, except the rjs and haml templates. Why not using .js.erb? Well, the answer is quite simple.

If someone ever came up with a plugin that does the same Javascript actions for some templates. Those templates could be called .js.dudesplugin . You see now? It all makes sense. Rails is all about convention, so it wouldn’t make sense to make an exception from the naming scheme for RJS templates.

Exit mobile version