我正在使用 Rails 3.2.1,我必须包含一些控制器和特定于操作的 Javascript。为此,我使用 a_javascript_template_manager.html.haml
并在页面底部调用它。现在我想将所有这些js合二为一,以减少http请求。我正在使用资产管道。
如何将特定于控制器的 js 合并到一个预编译文件中?
这是我的_javascript_template_manager.html.haml
文件的样子
%noscript
:css
#container{ display:none; }
= render :partial => "/widgets/common/javascript_disabled"
= jquery_include_tag :google
= javascript_include_tag "common"
/ condetional javascripts for the app
- if params[:controller] == "settings"
= javascript_include_tag "plugins/jQuery-cookie"
- if params[:controller] != "people" and params[:controller] != "companies"
= javascript_include_tag "plugins/iphone-style-checkboxes"
- if params[:controller] == 'users' || params[:controller] == 'companies'
= javascript_include_tag "plugins/best_in_place"
- if params[:controller] == 'letters' || params[:controller] == 'companies'
= javascript_include_tag "plugins/jquery.autoSuggest"
- if params[:controller] == 'people' || params[:controller] == 'letters' || params[:controller] == 'users' || params[:controller] == 'companies'
= javascript_include_tag "plugins/areacomplete"
= javascript_include_tag "application"
现在我想将上述所有 javascript 文件合并为一个,或者最好的方法是什么?