I've been reading up about HAML/SASS lately and I'm not quite sure why any one would not want to use it. It seems to be very easy to switch, makes things cleaner and more efficient.
我最近一直在阅读关于HAML/SASS的文章,我不确定为什么没有人不愿意使用它。它似乎很容易转换,使事情更干净和更有效率。
Update:
更新:
What about using one or the other? Most of the complaints (the few complaints there are) I hear seem to be about HAML, would there be any problems mixing and matching XHTML/HAML and CSS/SASS?
使用一个或另一个怎么样?我听到的大多数抱怨(为数不多的抱怨)似乎都是关于HAML的,混合和匹配XHTML/HAML和CSS/SASS会有什么问题吗?
Update:
更新:
Sorry, one final update to the question. It seems to me that switching back from SASS to CSS is painless and simple. What about switching back from HAML to HTML?
不好意思,最后一个问题。在我看来,从SASS切换回CSS很简单。从HAML切换回HTML怎么样?
11
If you're using Rails, yes. Go for it. Some issues you will hit, though, will be that any other developer brought onto the team later will have to learn it, as well. If you're already working with a big Rails crowd, that's fine, but HAML/SASS may confuse a designer who's worked with pure HTML/CSS for years.
如果你正在使用Rails,是的。就去做吧。但是,您将会遇到的一些问题是,任何其他开发人员在稍后引入到团队中,也将不得不学习它。如果您已经在与大量的Rails用户一起工作,那是可以的,但是HAML/SASS可能会让使用纯HTML/CSS多年的设计师感到困惑。
If you're not using Rails, though, a good HAML/SASS integrated system is hard to come by. There are a few out there, but I imagine they're not as well-supported or as far along with the spec.
但是,如果您不使用Rails,那么很难获得一个好的HAML/SASS集成系统。有一些在那里,但我认为他们不是很好的支持,或与规格一样远。
But, yeah. HAML/SASS is definitely worth it. The only real issue you'll hit is that it's not yet standard.
但,是的。HAML/SASS绝对值得。你唯一会遇到的问题是它还不是标准的。
As for mix-n-match, HAML and SASS are so similar in style that I'd say go for both, but it, again, comes down to personal preference. Try using both for a day, and if you don't like one of them, switch back. There's no technological issue about it, so do what you prefer.
至于mix-n-match, HAML和SASS在风格上是如此相似,所以我想说两者都有,但这又取决于个人喜好。试着把这两种都用一天,如果你不喜欢其中一种,那就换回去。这没有技术问题,所以你喜欢怎么做就怎么做。
6
There are lots of tools for working with HTML and CSS. The syntax isn't pretty, but the improvements from HAML and SASS don't seem that dramatic to me, and for many they're not worth the trouble. Of course, for those developing web application with widely differing frameworks (differing from Rails that is) it's even harder to find a reason to go to the pain of integrating something so foreign. (Example: care to explain what I'd have to do to integrate SASS into my Java/Stripes/JSP environment? :-)
有很多工具可以使用HTML和CSS。语法不是很好,但是HAML和SASS的改进在我看来并不是那么引人注目,对许多人来说,它们不值得麻烦。当然,对于那些使用不同框架(不同于Rails)开发web应用程序的人来说,很难找到一个理由去集成如此外国的东西。(示例:请解释一下要将SASS集成到Java/Stripes/JSP环境中需要做什么?):-)
5
I've been on volunteer projects where HAML's syntax curve (syntactical whitespace, the automatic generation of tags etc) has been seen as a barrier: one more thing for a programmer new to the project to learn.
我曾参与过一些志愿者项目,在这些项目中,HAML的语法曲线(语法空白、自动生成标签等)被视为一个障碍:对于一个刚进入项目的程序员来说,还有一件事需要学习。
Personally, I think SASS is worth it, but I'm up in the air about HAML: having debugged HAML templates before it seems like the typing you don't have to do with HAML is overcome by the time you spend debugging why there's an error on your templates. This could be a (HAML) newbie's perspective though.
就我个人而言,我认为SASS值得这么做,但我对HAML还是举棋不定:在HAML模板上调试过之后,就好像你不用HAML来进行输入一样,当你花时间调试为什么你的模板上有错误的时候,你就会克服这个问题。这可能是一个(HAML)新手的观点。
3
I'm inclined to agree with the question; it is easy to switch, the syntax isn't that complicated, and it does make things cleaner and more efficient. It also makes it harder to unwittingly generate invalid HTML.
我倾向于同意这个问题;它很容易转换,语法也不那么复杂,而且它确实使事情更简洁、更高效。这也使得在不知情的情况下生成无效的HTML更加困难。
I also think the learning curve is shallow enough that a programmer that can't handle it, is probably a programmer you are better off without on your team. That might sound harsh, but I believe it.
我还认为学习曲线很浅,程序员无法处理,很可能是程序员,而不是团队。这听起来可能有些刺耳,但我相信。
The only cons I can see would be if you are developing in ASP.NET or something where retrofitting Haml and Sass would be a pain, is way unexpected for anyone else used to the platform, and possible a chore to maintain in a production environment. On Rails though, go for it.
我能看到的唯一缺点是如果你在ASP开发。NET或任何对Haml和Sass进行改造会很痛苦的东西,对于任何习惯于这个平台的人来说都是意想不到的,并且可能是在生产环境中维护的一件苦差事。尽管在轨道上,去做吧。
2
I don't think that using HAML ever adds much benefit to a project.
我不认为使用HAML会给项目带来什么好处。
SASS, on the other hand, effectively introduces variables and computations and other really useful features that save you time and effort in the long run on larger projects.
另一方面,SASS有效地引入了变量、计算和其他真正有用的特性,这些特性可以节省您在大型项目上长期运行的时间和精力。
Using SASS is incredibly smart with any project that's larger than just a simple one-page form.
使用SASS对于任何比简单的单页表单更大的项目来说都是非常聪明的。
2
I tried using SASS but found that editing CSS using MacRabitt's CSSEdit (Mac Only) was way easier and more efficient for the way I work. I'm a very visual person and like to have a live preview when making changes to style sheets and didn't feel like investing a ton of time into something I wasn't having a problem with.
我尝试使用SASS,但发现使用MacRabitt的CSSEdit(仅适用于Mac)编辑CSS对我的工作方式来说更容易、更有效。我是一个非常有视觉的人,喜欢在修改样式表时进行实时预览,并且不想花大量时间在我没有问题的事情上。
2
One thing most people don't realize is that HAML sucks for content. It's great for structural markup, but don't try and push it too far. (You can mix & match HTML in your HAML file, too!)
大多数人没有意识到的一件事是HAML很烂。这对于结构化标记很有用,但是不要尝试太过分。(您也可以在HAML文件中混合和匹配HTML !)
Sass is absolutely indispensable, especially in the long run. It's not just about writing the stylesheets when you have it all in your head, but about maintaining them down the road. The new Sass3 takes the syntax question out of the equation: you can take your pick if you prefer the curly-bracey SCSS syntax.
Sass是绝对不可或缺的,尤其是从长远来看。这不仅仅是在脑子里有了样式表之后编写样式表,而是在以后维护它们。新的Sass3将语法问题从等式中去掉:如果您喜欢卷曲的SCSS语法,可以选择。
1
HAML/SASS may indeed be awesome to use, but they do introduce dependencies both technical and knowledge-oriented. This may not be an issue if your dev and prod environments are controlled and predictable enough, with newbies receiving enough training (or being vetted for subject knowledge on the way into the organization) to hit the ground running, but all of that is overhead to be acknowledged.
HAML/SASS使用起来确实很棒,但是它们引入了技术上的依赖和面向知识的依赖。如果您的开发和prod环境受到足够的控制和足够的预测,这可能不是一个问题,因为新手接受了足够的培训(或者在进入组织的过程中接受了专业知识的审查),但是所有这些都是需要承认的。
1
why is this..
这是为什么. .
%p
hello world
better than this..?
比这更好. . ?
hello world
clue.. If you aren't doing ruby, it isn't. Unfortunately adding closing tags and braces isn't really the most challenging aspect of making webpages, so most professionals wouldn't really care. Use whichever you prefer.
线索……如果你不做ruby,那就不是。不幸的是,添加关闭标签和大括号并不是制作网页最具挑战性的方面,所以大多数专业人士不会真正在意。使用您喜欢的任何一个。
0
From a developer's perspective, Haml and Sass absolutely rock. However: from a designer's perspective, Haml and Sass might not be readable. It really depends on who is on your team.
从开发人员的角度来看,Haml和Sass绝对是摇滚。然而:从设计师的角度来看,Haml和Sass可能是不可读的。这取决于你的团队是谁。
If it's a bunch of developers and/or designers who aren't afraid to learn a DSL, then absolutely go for it.
如果有一群开发人员和/或设计人员不害怕学习DSL,那么一定要去学习它。
If you have a mixed team where designers toss their CSS and HTML work to developers who translate that to Haml/Sass, sure.
如果你有一个混合的团队,设计师把他们的CSS和HTML工作扔给那些把它翻译成Haml/Sass的开发人员,当然。
If you have a design team that passes work to the developers AND the work flows back to the designers, you may not want to use this because the designers might not be able to use their tools to edit the files.
如果您有一个将工作传递给开发人员的设计团队,并且工作流返回给设计人员,您可能不希望使用它,因为设计人员可能无法使用他们的工具来编辑文件。
If you have a small team where marketing and business people need to edit the web pages and they only know HTML and a light bit of CSS, then you probably shouldn't use Haml/Sass.
如果你有一个小团队,营销人员和商务人员需要编辑网页,他们只知道HTML和一点CSS,那么你可能不应该使用Haml/Sass。
However you can't really make a blanket statement here. Consider that at least with Rails you can mix the template types in your views. So, some of your templates can be plain HTML stuck in .erb files, and other pages are .haml files. You can have partials be of one type inserted into templates of another. (I think mixing types is probably a bad practice, but if you just need to "get the job done" then it's an option.)
但是你不能在这里做一个全面的陈述。考虑到至少可以使用Rails在视图中混合模板类型。因此,您的一些模板可以是普通的HTML卡在.erb文件中,其他页面可以是.haml文件。可以将一种类型的部分插入到另一种类型的模板中。(我认为混合类型可能是一种不好的做法,但如果你只是需要“完成工作”,那么这是一种选择。)
0
I am using SASS on a Django project right now. I like it and am going to continue using it. One problem I've found however is that error messages aren't always particularly intuitive, particularly if you leave off a }
.
我正在Django项目中使用SASS。我喜欢它,并将继续使用它。然而,我发现一个问题是错误消息并不总是特别直观,特别是如果您省略了}。