views:

292

answers:

1

I'm not sure I understand the difference between the html.erb files and erb files in the views for a Ruby on Rails application. (Similarly for haml files.)

What are the dis/advantages of each (html.erb/haml or erb/haml) files?

PS I'm not asking about the difference between the erb and haml files -- just appending the extension to an html file versus not appending it.

+1  A: 

Look at this http://railsforum.com/viewtopic.php?id=33111

Gabriel Ščerbák
Soo, the post says that it depends on what the action "responds to". I'm not sure what that means... Clarification?Also, it doesn't explain html.erb vs just the .erb extension really...
Teef L
The post basically says that it is up to you how you will name the file, only the "erb" extension is needed. However, Ruby on Rails application can respond for requests different than html only. Take for example AJAX - this sends request in javascript. There are also other types, for example if you would like to create a web service (SOA), you would have to answer to xml requests with xml. You can also serve JSON, e.g. as a part of some API.
Gabriel Ščerbák
Now imagine you have an action (controller method) which can respond with different types. Which view template to use is than determined with second extension as in "html.erb" or "js.erb".
Gabriel Ščerbák