我在使用aptana studio 3的rails上學習ruby。我創建了一個視圖hello.rhtml。當我運行視圖,看到源我看到js文件自動包括。即使我的RHTML文件是空的如Aptana studio 3自動在html文件中包含html標記
hello world
沒有HTML標記,如果我看到的來源,我可以看到從HTML文檔類型等已經存在的全部標記。我如何停止包含自動標記?
感謝
編輯:
OK我創建了一個hello.html.erb文件。當我保存並運行該文件,我得到的輸出,但是當我查看源代碼我得到以下結果把這段代碼裏面
你好
。
<!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>
所以如果你看到,我得到的HTML裏面的html,當在瀏覽器中我的標題顯示「演示」,而不是「你好」
更新:
這裏是應用程序的內容佈局。我現在明白了,代碼來自這個佈局。
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>
<%= yield %>
</body>
</html>
我是新來的這一點,所以什麼是最好的做法,哪些代碼應該出現在application_layout.html.erb。我希望我所有的視圖文件都有自己的html代碼。 非常感謝
我編輯了我的問題。基本上我得到它的HTML標記的HTML標記。如果我在我的.html.erb文件中編寫html代碼並運行代碼,我仍然可以在我的視圖源中看到html代碼。 – noobcode
看到我的更新。我現在明白,我的概率是因爲application_layout.html.erb ...你可以建議同樣的最佳選擇嗎?..謝謝 – noobcode
我刪除了application_layout.html.erb中的所有其他代碼,並且僅使用<%= yeild %>。它的工作方式就像我希望它的工作......希望這是一個最佳實踐。謝謝 – noobcode