3 ms·
The thing I don't like about all these ways to "improve" HTML/CSS is that they all seem to assume the rest of the webapp ecosystem doesn't exist. Take SASS's v
by nostrademons 17y ago
The thing I don't like about all these ways to "improve" HTML/CSS is that they all seem to assume the rest of the webapp ecosystem doesn't exist.
Take SASS's variables and arithmetic, for instance. I agree that CSS desperately needs some way to abstract out common values. But any decent webapp will already be using some sort of template system, and the template system will have some sort of variable. Why not use it and be consistent with the rest of your UI? If you introduce SASS into the mix, you just have to do things one way in your CSS and another way in your markup.
Same thing with Zen Coding. Instead of using an editor plugin that expands abbreviations (which then have to be maintained), why not use your template system and avoid writing all that code in the first place? If I were writing the example listed here, it'd look something like this:
<div id=menu>
<table>
<tr>
{{#CELL}}<td><a href="" class=nav></a>{{/CELL}}
</table>
</div>
(That's using google-ctemplates because it's what I work with daily, but substitute in Django, Cheetah, Mako, or erb as necessary.)
Yes, there's still room for improvement, and yes, I wish my editor were more aware of available template variables. But I also don't have to maintain the 5 separate <td> tags once I've typed them out, I can change one and have its updates be reflected across all the generated code. I can avoid those pesky closing tags by simply not typing them; the HTML spec doesn't require them, all browsers handle it fine, and it saves end-user latency as well. And I don't need to learn a new tool, I just have to use my existing tools better.
- harisenbon 17y agoI feel similarly about all these HTML improvements (although i would love some CSS variable action like in SASS). Almost any homepage I create that's not a one-shot throwaway for a client is going to running on top of some sort of framework. That means that for any table like this, I'm only going write a single row (at most), and then have my framework iterate over it and turn it into pretty code. I love any time-saving or code-saving functions and features in my code as much as the next guy, but this seems like an unnecessary complication to already rather streamlined coding. Also the fact that any IDE with decent auto-complete will be able to do the same thing with just three strokes instead of all that. (For example, in Eclipse if I type "<tab" then press enter, I get a fully formed pretty table in 5 key strokes.
- raimondious 17y agoI think there's a market for this in people who develop small brochure sites or for whipping up HTML comps. You have to start the template from something, no?
- regularfry 17y agoThe upside of having a system like SASS is that it can be a lot smarter about the underlying system it's generating content for, which you don't get if you use a general-purpose template system. Selector nesting in SASS is a good example of this. It makes both the styling and page structure a lot easier to understand, which is a bigger win in my book than the typing it saves. I see a system like Zen Coding not for tackling the same tasks as a template system, where the bulk of your work effort might be spent. It's for the irritating little bits around the edges where, instead of taking 5 minutes per page bashing out boilerplate, it now takes 30 seconds. Not a huge win, but a win nonetheless.
- gamache 17y agoYou could do CSS in a templating system, sure. First off, you'd want to cache it, but that's a solved problem. And you'd be well served to cook up some subtemplates/helpers/whatever that automated away some of the drudgery. Pretty soon you'd have more ideas on how to keep your CSS more maintainable, your subtemplates would become more general, etc. At this point you have implemented most of Sass/Less/etc but you have a bunch of templating gunk, less documentation, and hundreds fewer eyeballs looking at the code. Or, you have not implemented most of Sass/Less/etc and you are still writing CSS like a chump.
- nostrademons 17y agoBut it would be the same templating gunk that is used by the rest of your webapp, which most likely has more documentation and thousands more eyeballs looking at the code than Sass. Most people don't roll their own templating systems. They use an established library that's been battle-tested on websites before. These libraries have been around a lot longer than Sass/Haml has.