问题
In a simple website I'm working on, I have a directory haml
and a directory pages
. The haml folder contains the .haml files I work on, and the pages folder contains my converted .html files.
I know I can convert the files, from the website root directory, by doing:
haml haml/about.haml pages/about.html
for each file.
However, is there a way to convert all the .haml files in my haml folder to an equivalent .html file in the pages folder?
Something like: haml haml/*.haml html/*.html
Thanks!
回答1:
There is a nice html2haml gem for this purpose
and you can run it on a directory using
find . -name \*.erb -print | sed 'p;s/.erb$/.haml/' | xargs -n2 html2haml
回答2:
guard watches haml
files, compiles them, you can set an output dir as well.
https://github.com/guard/guard-haml sounds like an option.
回答3:
There's a python script that sounds like it will do exactly what you want...
I haven't tested it, but per the README, it sounds like it's as simple as:
python haml2html.py [input_dir] [output_dir]
来源:https://stackoverflow.com/questions/20746541/converting-all-haml-files-in-a-dir-to-html-in-another-dir