转换 **haml** 和 **scss** 文件的最快、最有效的方法? (Windows 上的 Ruby)
我是 ruby/haml/sass 初学者。我刚刚为 windows、haml 和 sass 安装了 ruby 和 Rails(独立的和 Rails 的插件)。
我知道如何将 haml 文件转换为 html 文件(反之亦然):
haml index.haml > output.html
以及如何将 scss 文件转换为 scss 文件>css 文件(反之亦然):
sass --watch style.scss:style.css
我可以节省更多转换 scss 文件的时间,因为每次我保存 scss 文件时都会保存相应的 css 文件会自动更新(我认为这是 watch 命令的假设),
但对于 haml 文件,我仍然手动更新(haml index.haml > output.html )。
我相信还有其他方法可以节省转换 haml 和 scss 文件的时间。
有什么建议吗?
I'm a ruby/haml/sass-beginner. I just installed ruby and rails for windows, haml, and sass (stand alone and plugin for rails).
I know how to convert and haml file into a html file (and vice versa):
haml index.haml > output.html
and how to convert a scss fiel into a css file (and vice versa):
sass --watch style.scss:style.css
I save more time converting scss files because every time I save a scss file the corresponding css file is automatically updated (i think that's the suppose of the watch command)
but for the haml files, I'm still doing it manually (haml index.haml > output.html
).
I believe there's other ways to save time converting haml and scss files.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您设置 Rails 以使用 Haml 时,请启动您的在开发服务器上,视图中的 Haml 会即时转换为 HTML,因此无需单独监视 Haml 的更改。
但是,如果您在此阶段仅使用 Haml 和 SCSS 创建原型,而不使用 Rails 堆栈,那么您可以使用一些有用的工具,在页面刷新时自动呈现 Haml 和 SCSS:
Serve< /强>
http://github.com/jlong/serve
StaticMatic
http://github.com/staticmatic/staticmatic
这两者中,Serve 更容易使用,但是不如 StaticMatic 强大。使用 Serve,您所需要做的就是安装它 (
gem installserve
) 并在包含 Haml 文件的目录中的命令行中键入serve
。然后将浏览器指向http://localhost:4000
。 完整详情请参见此处。您还可以连接 Serve 以使用 Compass Sass 元框架(非常棒)。这里有完整教程。
When you setup Rails to work with Haml, then start your development server, the Haml in your views get converted into HTML for you on-the-fly, so there's no need to watch for changes to your Haml separately.
However, if you're creating prototypes using just Haml and SCSS and not using the Rails stack at this stage, then there are a couple of useful tools you can use that automatically render your Haml and SCSS on page refresh:
Serve
http://github.com/jlong/serve
StaticMatic
http://github.com/staticmatic/staticmatic
Of these two, Serve is easier to use, but is not as powerful as StaticMatic. With Serve, all you need to do is install it (
gem install serve
) and typeserve
at the command line in the directory containing your Haml files. Then point your browser athttp://localhost:4000
. Full details here.You can also hook-up Serve to make use of Compass the Sass meta-framework (which is awesome). There's a full tutorial here.
哦,现在也有动态的,这可能也值得研究一下。基本上与静态类似,但有一些可能有用的明显差异。我最近经常使用SM并且非常喜欢它。非常容易使用,设置也非常简单,并且确实可以完成我需要的大部分事情。
Oh, there's also dynamicmatic now too which might be good as well to look into. Basically similar to staticmatic but with some obvious differences that might be useful. I've used SM quite a lot recently and really like it. Very easy to use, very simple to set up and really does most things I need it to.