Creative Rails English French

Convertir ses fichiers erb en haml rapidement

Un petit script bien pratique pour les fans d’haml.

class ToHaml def initialize(path) @path = path end

def convert! Dir[“#{@path}//.erb”].each do |file| `html2haml -rx #{file} #{file.gsub(/\.erb$/, ‘.haml’)}` end end

end

path = File.join(File.dirname(FILE), ‘app’, ‘views’)
ToHaml.new(path).convert!

A placer dans un fichier à la racine du projet pour l’executer.

© Copyright 2009 Creative Rails Liens : Solisoft, AGSI