首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

thor相干

2012-10-17 
thor相关注意,在rails里用thor,thor类名不要和model类名起成一样,thor会优先加载lib/tasks/下面所有的thor

thor相关
注意,在rails里用thor,thor类名不要和model类名起成一样,thor会优先加载lib/tasks/下面所有的thor类。

erb to haml

lib/tasks/erb.thor

# Add the following to your Gemfile:## gem 'haml'# group :development do#   gem 'hpricot'#   gem 'ruby_parser'# endrequire 'haml'require 'hpricot'require 'ruby_parser'class Erb < Thor  desc "to_haml", "convert erb views to haml"  def to_haml    files = `find app/views -name *.erb`    files.each_line do |file|      file.strip!      target = file.gsub(/\.erb$/, ".haml")      next if File.exist? target      puts "#{file}"      `bundle exec html2haml #{file} | cat > #{target}`    end  endend

热点排行