我創建Haml的助手,並把它作爲路徑應用程序/傭工/ haml_helper.rb文件如何將自定義的Haml助手添加到Rails項目中?
module Haml::Helpers
def build_segment(files)
files.each do |f|
if f[:dir] == nil
haml_tag :li do
haml_tag :a, :class=>"file", :href=>f[:name] do
f[:name]
end
end
else
haml_tag :li do
haml_tag :a, :class=>"folder", :href=>f[:name] do
f[:name]
end
end
haml_tag :ul do
build_segment(f[:dir])
end
end
end
end
end
但後來我得到了一個錯誤:
LoadError in SourceFilesController#index
Expected /home/megas/Work/read_the_code/app/helpers/haml_helper.rb
to define HamlHelper
SourceFilesController#指數是將使用這個定製助手的動作。
如何將自定義haml幫助程序添加到項目中?
嘗試/helpers/haml/helpers.rb –
它的伎倆 – megas