htmlruby-on-railsaptana

Aptana studio 3 automatically includes html markup in rhtml files


I am learning ruby on rails using aptana studio 3. I created a view hello.rhtml. When I run the view and see the source I get to see js files automatically included. Even if my rhtml file is empty for eg

hello world

Without the html markup, and if I see the source, I can see the entire markup from html doctype etc already present. How do I stop the inclusion of automatic markup?

EDIT:

I create a hello.html.erb file. And put this code inside it

Hello

When I save and run the file, I get the output, but when I view source I get the following result.

<!DOCTYPE html>
<html>
<head>
  <title>Demo</title>
  
  <script src="/javascripts/prototype.js?1312799421" type="text/javascript"></script>
<script src="/javascripts/effects.js?1312799421" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1312799421" type="text/javascript"></script>
<script src="/javascripts/controls.js?1312799421" type="text/javascript"></script>
<script src="/javascripts/rails.js?1312799421" type="text/javascript"></script>

<script src="/javascripts/application.js?1312799421" type="text/javascript"></script>
  <meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="82LBP1pI5h0QzNW54PYSq/zdkS8kF4Z/nKSUHgKvv1g="/>
</head>
<body>

<html>
  <head><title>Hello</title></head>
  <body>
</body>
</html>


</body>
</html>

As you see, I get html inside html and when in browser my title shows "Demo" instead of "Hello"

Update:

Here is the content of application layout. And I now understand that, the code is coming from this layout.

<!DOCTYPE html>
<html>
<head>
  <title>Demo</title>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

</body>
</html>

What is the best practice and what code should be present in application_layout.html.erb? I would like all my view files to have its own html code.


Solution

  • Your view should have .html.erb extension not rhtml (That's a hang over from Rails 1.x). Check out your application layout file. in the head section you'll see an entry for including JavaScript. Just comment that out and you js will not be included.

    UPDATE Have a close look at your application_layout.html.erb.