如何从一个警卫“管道”输入到另一个警卫?

时间:2013-02-11 20:08:53

标签: guard

我正在尝试防范,我想用haml编写把手模板。有没有办法将guard-haml的输出“管道”到防护把手(即有2个防护装置在同一个文件上运行)?或者,是否有一个可以执行这两个步骤的防护插件?

1 个答案:

答案 0 :(得分:0)

使用guard-shell拼凑解决方案。根本问题是,防护手柄要求它的输入文件以“.handlebars”结尾,并且没有配置选项来改变它。而不是修补防护手柄,我只是使用guard-shell在guard-haml处理它们之后重命名文件。以下是我的Guardfile中生成的代码:

guard 'haml', :input => 'src/templates', :output => 'public/js/templates/html' do
    watch %r{^.+(\.hbs\.haml)$}
end

guard :shell do
  watch %r{^public/js/templates/html/.+(\.hbs\.html)$} do |m|
    path = m[0]
    new_path = path.gsub(/\.hbs\.html$/, '.handlebars')
    `mv #{path} #{new_path}`
  end
end

guard 'handlebars', :input => 'public/js/templates/html', :output => 'public/js/templates' do
  watch %r{^.+(\.handlebars)$}
end
相关问题