Converting all .haml files in a dir to .html in another dir

試著忘記壹切 提交于 2019-12-23 17:17:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!