0
我正在嘗試使用稱爲Manifesto的寶石的HTML5清單函數。我堅持使用說明。我無法弄清楚這些設置應該放在哪裏。使用Rails 3寶石宣言
任何想法?也許是更好的寶石?
https://github.com/johntopley/manifesto#readme
感謝所有幫助!
我正在嘗試使用稱爲Manifesto的寶石的HTML5清單函數。我堅持使用說明。我無法弄清楚這些設置應該放在哪裏。使用Rails 3寶石宣言
任何想法?也許是更好的寶石?
https://github.com/johntopley/manifesto#readme
感謝所有幫助!
你可以把你的設置放在config/initializers/
下的文件中。使用信息名稱(如manifesto.rb
)。但是,您不需要具有基本用法的配置。
在你Gemfile
文件,添加:
gem 'manifesto'
然後通過捆綁安裝:
bundle install
在config/routes.rb
添加創建文件app/controllers/manifest_controller.rb
class ManifestController < ApplicationController
def show
headers['Content-Type'] = 'text/cache-manifest'
render :text => Manifesto.cache, :layout => false
end
end
:
match '/manifest' => 'manifest#show'
重新啓動應用程序並查看結果在http://localhost:3000/manifest
您可以直接通過選項Manifesto.cache
,如:
# change
render :text => Manifesto.cache, :layout => false
# to
render :text => Manifesto.cache(:directory => './mobile', :compute_hash => false), :layout => false
或者使用一個YAML文件和初始化。
的config/manifesto.yaml
文件:
# directory is relative to Rails root
directory: './mobile'
compute_hash: false
的config/initializers/manifesto.rb
文件:
# Load the config file and convert keys from strings in symbols (the manifesto gem need symbolized options).
MANIFESTO_CONFIG = YAML.load_file(Rails.root.join('config', 'manifesto.yml').to_s).inject({}){|config,(k,v)| config[k.to_sym] = v; config}
而調入的配置傳遞給Manifesto.cache
,如:
# change
render :text => Manifesto.cache, :layout => false
# to
render :text => Manifesto.cache(MANIFESTO_CONFIG), :layout => false
看起來不錯,謝謝!我把什麼放在manifesto.rb文件中? – 2010-11-23 19:26:56