<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - Precompiling CSS with Extensions - A Crazy Idea? - Comments</title>
 <link>http://www.developerdotstar.com/community/node/505</link>
 <description>Comments for &quot;Precompiling CSS with Extensions - A Crazy Idea?&quot;</description>
 <language>en</language>
<item>
 <title>CSS Organization</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1260</link>
 <description>&lt;p&gt;As a complement to this thread, I later encountered &lt;a href=&quot;http://www.digital-web.com/articles/architecting_css/&quot;&gt;this nice article in Digital Web Magazine about &quot;architecting&quot; CSS files&lt;/a&gt; to avoid the potential for the spaghetti effect discussed above. Worth a read if you&#039;re starting a new project and have not yet decided how to organize your CSS.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Tue, 11 Jul 2006 12:39:54 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 1260 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>This is not a crazy idea</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1221</link>
 <description>&lt;p&gt;Years ago I needed something like that for HTML (mainly to auto-create a dynamic menu - well, static for each file, but slightly different from file to file). I ended up creating my own text editor (with syntax highlightning, there is free code around for that) and added a simple precompiler to it. The syntax is somehow similar to PHP: with special tags I can define constants, use them, add if/then/else, include other files, pass &quot;parameters&quot; to these files (which makes them look like procedures) etc. I&#039;ve decided to have special extensions for &quot;uncompiled&quot; texts like .uhtml, .utxt... and of course .ucss is possible, too. A simple click compiles the .uwhatever to a .whatever, replacing all constants, including other files after compiling them, too, etc. It&#039;s even possible to create projects with a simple command which compiles a file without including it. I&#039;ve never published this editor/compiler because it is too premature, but I&#039;m still using it from time to time, and I still find it useful to have such a precompiler for texts. So I really think this is not a crazy idea.&lt;/p&gt;
</description>
 <pubDate>Sun, 25 Jun 2006 01:53:07 -0700</pubDate>
 <dc:creator>Jens</dc:creator>
 <guid isPermaLink="false">comment 1221 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Create CSS using a template engine</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1218</link>
 <description>&lt;p&gt;Some of your ideas could be solved by creating CSS code using&lt;br /&gt;
a template engine.  Usually template engines, e.g. Cheetah&lt;br /&gt;
(&lt;a href=&quot;http://cheetahtemplate.org/&quot; title=&quot;http://cheetahtemplate.org/&quot;&gt;http://cheetahtemplate.org/&lt;/a&gt;) are used to create HTML, but&lt;br /&gt;
you can actually use them for creating anything, including CSS.&lt;br /&gt;
I&#039;ve used Cheetah to create Postscript, PHP, XML and plain text.&lt;br /&gt;
However, I&#039;m not sure how practial this would be.&lt;/p&gt;
</description>
 <pubDate>Sat, 24 Jun 2006 22:07:51 -0700</pubDate>
 <dc:creator>Ilan Schnell</dc:creator>
 <guid isPermaLink="false">comment 1218 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>CSS GOTOs</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1217</link>
 <description>&lt;p&gt;Robert, thanks for all the comments, and yet another solution! I only have a moment for a quick reaction. You wrote:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;I have a better understanding of wanting a tool that can understand CSS well enough to refer to information from other rules, but I&#039;m having quite a bit of trouble seeing what it buys CSS developers. The way I see it, what you&#039;re asking for, if used in real life, will result in CSS that looks like spaghetti code - you&#039;re simply using named GOTO&#039;s.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a fair concern, and one I&#039;ll have to think about. It might mean trying some scenarios with an imagined syntax and seeing how it comes out. I might also argue that CSS already has a serious tendency towards spaghetti-ness. For the recent rewrite of this site&#039;s design, which is built within the PHP Template engine of Drupal, as well as in a separate publishing system I use for the articles side of the house, I know the CSS got a little complex. I split the CSS into separate files, and you can develop some concept of namespaces to keep things organized and to allow for variation of the same page elements on different kinds of pages. You do have to go to some effort to keep things clean. And it seems there can be side effects that make the built in CSS inheritance mechanisms not do what you need all the time.&lt;/p&gt;
&lt;p&gt;I guess my point is that these ideas were hatched while in the midst of this site redesign, so I&#039;m inclined to give them some credence, but it&#039;s certainly possible that you are right that basic string replacement functionality is enough to streamline the redundancies.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;
Dan&lt;/p&gt;
</description>
 <pubDate>Sat, 24 Jun 2006 21:54:13 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 1217 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>gm4 version done.</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1216</link>
 <description>&lt;p&gt;Dan, Dennis, and others...&lt;/p&gt;
&lt;p&gt;You might want to check out my update to this -- I set it up using the gm4 macro processor, which ended up being as simple to use, and quicker to implement, than I had expected.  See &lt;a href=&quot;http://blog.roberthahn.ca/articles/2006/06/24/css-preprocessor-â€“-take-2&quot;&gt;CSS Preprocessor - Take 2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Again, still not your ideal language-that-understands-CSS ideal, but we may have to agree to disagree on that point. I just don&#039;t see the advantages inherent in that strategy.  Do let me know if you actually use this in a project though; I&#039;d like to hear how it worked out.&lt;/p&gt;
</description>
 <pubDate>Sat, 24 Jun 2006 17:54:41 -0700</pubDate>
 <dc:creator>roberthahn</dc:creator>
 <guid isPermaLink="false">comment 1216 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>I&#039;m back.</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1215</link>
 <description>&lt;p&gt;Sorry about my blog not accepting your post; I found out this morning, right before running out with my  family for the day that the server I&#039;m on went belly-up. It&#039;s a shared server, so the usual presumption at this point is that some over-enthusastic developer tried to do something that consumed too much of the server&#039;s resources. Anyhow: the blog&#039;s back up and running.&lt;/p&gt;
&lt;p&gt;Thank you very much for your kind words. I too saw this as a first cut at the solution, and had this mostly written up before I discovered the problem with #foo and cpp.  Before seeing Dennis&#039; and your comments on that problem, I mostly convinced myself that it wasn&#039;t that bad.  As an aside: I&#039;m not quite following Dennis&#039; issue with the &quot;piggybacking on the C code&quot; - Dennis, if you&#039;re reading this, please understand that the C preprocessor has nothing to do with the C language - the people who wrote it designed it to specifically solve their problem with writing lots of C code. The preprocessor can be used with other languages, and other text files (and indeed, this is how I used it).&lt;/p&gt;
&lt;p&gt;In any event, I&#039;m going to have a look at using gm4, which won&#039;t have this conflict with id selectors.  I realized, after posting my article, that for this type of exercise, gm4 might be a better fit -- the problem with gm4 is that it&#039;s too powerful, it&#039;s really hard for many developers to pick up, and can match things a tad too aggressively if you set it up wrong.  For those reasons I instinctively reached for CPP.&lt;/p&gt;
&lt;p&gt;After reading carefully through your post and this response, Dan, I have a better understanding of wanting a tool that can understand CSS well enough to refer to information from other rules, but I&#039;m having quite a bit of trouble seeing what it buys CSS developers.  The way I see it, what you&#039;re asking for, if used in real life, will result in CSS that looks like spaghetti code - you&#039;re simply using named GOTO&#039;s.&lt;/p&gt;
&lt;p&gt;In the case where you want your li and blockquote rules share the same font size definition, I&#039;d probably still would want to just define it in a set of constants (using names like default, caption, header1, header2, header3), and, if I find I&#039;d need to tweak a size, I&#039;ll either adjust it on a &#039;global level&#039; or simply change which constant to use.  For arithmetic support, well, maybe using gm4 might actually help here, because it promises arithmetic support -- you&#039;ll have to get pretty savvy with the macro definitions though, to split the numbers from the units, do the math, and merge it back in -- and then that doesn&#039;t help solve the problem of wanting to merge 12pt with 0.8em.&lt;/p&gt;
&lt;p&gt;I&#039;ll post another update here if I get the gm4 version working.  I really like this basic architecture (a sh script executing multiple preprocessor commands, all executed by launchd), and fully intend to add this to my arsenal of tools as well.  The strong point in the arch is that you can swap out the cpp part for anything, and the rest of the infrastructure would require only minimal changes to accommodate.&lt;/p&gt;
</description>
 <pubDate>Sat, 24 Jun 2006 16:34:39 -0700</pubDate>
 <dc:creator>roberthahn</dc:creator>
 <guid isPermaLink="false">comment 1215 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Reply to Robert&#039;s CPP Solution</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1213</link>
 <description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I wrote the following comment to Robert Hahn&#039;s excellent post and solution, to which Robert links in this comment up-thread. However, I think Robert&#039;s server was having some trouble at the same time I was posting the comment, so I am pasting the comment below.&lt;/p&gt;
&lt;p&gt;Best,&lt;br /&gt;
Dan&lt;/p&gt;
&lt;p&gt;*****&lt;/p&gt;
&lt;p&gt;Robert, this is great! Thanks for taking the time. In addition to being a nice initial solution to the problem, it&#039;s an excellent demonstration of the power of generic tools like CPP and launchd. While reading your post, I was thinking of how easy it would have been for the original designer of CPP to make the tool less generic.&lt;/p&gt;
&lt;p&gt;The clash between CSS and CPP on the meaning of the # character is an unfortunate side effect, even more so because I use this convention in my CSS liberally--that is, starting a style definition with the # character, as in your example foo:&lt;/p&gt;
&lt;div class=&quot;codeblock&quot;&gt;
&lt;pre&gt;#foo {&lt;br /&gt;    ...&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I suppose CPP could have been designed to be even more generic if the definition marker character was configurable. Easy to criticize the play from home after the match has already been played.&lt;/p&gt;
&lt;p&gt;Previously, Robert, I described your solution as an &quot;initial solution.&quot; In this, I meant no disrespect, because I think it&#039;s infinitely cool that you&#039;ve put this together. I&#039;m going to give it a run myself for a new site I&#039;m about to build, and I suspect others will find it useful also. Not to mention, I suspect others will find inspiration from the creative application of CPP.&lt;/p&gt;
&lt;p&gt;You mentioned in your post that you had only skimmed my original post, which is cool, and regardless, I might have not done the best job explaining my overall&lt;br /&gt;
&quot;extensions&quot; idea, which includes more than the string-replacement functionality from my first &quot;const&quot; example--a problem which is solved nicely by your CPP-based solution. I think a full implementation of the &quot;extensions&quot; idea would need to have more semantic awareness, if that phrase is appropriate, of the specific structure of the CSS code.&lt;/p&gt;
&lt;p&gt;What I mean is, I would also love to have that ability to refer to other styles in a manner where this &quot;precompiler&quot; would understand the other styles defined in the scope of one or more designated CSS files as &quot;objects.&quot; This to me implies the need to initially parse all of the designated CSS files to build a graph in memory of unique style &quot;objects,&quot; kind of like parsing an XML file to build a DOM.&lt;/p&gt;
&lt;p&gt;In addition, the ideal solution I can imagine at this point (and I&#039;m not pretending to be the most qualified person to do so) would have some ability to evaluate simple expressions and functions, such as the example of saying &quot;I want this lineheight attribute value to be .1em less than the lineheight attribute of that other style over there.&quot;&lt;/p&gt;
&lt;p&gt;Thanks also for the introduction to the term &quot;lazyweb request.&quot;&lt;/p&gt;
&lt;p&gt;Best,&lt;br /&gt;
Dan&lt;/p&gt;
&lt;p&gt;P.S.&lt;br /&gt;
The timing with the Slashdotted interview you mentioned is coincidental. I&#039;ve been sitting on this idea for awhile and finally the other night decided to blog on it since it was clear I was not going to have the time to do something with the idea myself. I imagined, however, that I could not have been the first person to think such thoughts. The need for these kinds of &quot;extensions&quot; would be apparent I think to a lot people coding CSS of interesting complexity from scratch. I&#039;ll have to go read that interview.&lt;/p&gt;
</description>
 <pubDate>Sat, 24 Jun 2006 08:40:10 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 1213 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>CSS compiler...</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1210</link>
 <description>&lt;p&gt;I too have had this very thought.  At the time, ignorant of the CSS specification, I searched in vain for such an animal in the wild w3.  I eventually came across the spec, and my dream was flattened, but still alive.  I considered writing a Q&amp;amp;D VB EXE that would pre-process my css and never found the time.  Roberts suggestion is much cleaner that I would have come up with, but I don&#039;t like the fact that it piggy backs on the c code, thus losing native CSS functionality...  I&#039;ll check back and see if ayone else solves this ...  It would be interesting to see if the W3C could justify it&#039;s inclusion in the next CSS Spec, however unlikely that rteally is....  Thanks for your thoughts.  D.&lt;/p&gt;
</description>
 <pubDate>Fri, 23 Jun 2006 21:09:05 -0700</pubDate>
 <dc:creator>Dennis Nagel</dc:creator>
 <guid isPermaLink="false">comment 1210 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Built it.</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1209</link>
 <description>&lt;p&gt;Hey, Daniel.  &lt;a href=&quot;http://blog.roberthahn.ca/articles/2006/06/24/css-preprocessor&quot;&gt;Here&#039;s how I decided to tackle this problem&lt;/a&gt;, using the aforementioned C preprocessor to do the heavy lifting. I hope this&#039;ll work for you.&lt;/p&gt;
</description>
 <pubDate>Fri, 23 Jun 2006 19:10:50 -0700</pubDate>
 <dc:creator>roberthahn</dc:creator>
 <guid isPermaLink="false">comment 1209 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>CPP? gm4?</title>
 <link>http://www.developerdotstar.com/community/node/505#comment-1208</link>
 <description>&lt;p&gt;If I were to tackle this problem, I&#039;d probably just use the C Preprocessor (CPP) and use C-style #define&#039;s or #include&#039;s, or define a set of m4 macros.  Then, each time I make a change to this enhanced stylesheet, I&#039;d run &lt;/p&gt;
&lt;p&gt;cpp styles.csse styles.css&lt;/p&gt;
&lt;p&gt;and be done with it. It would be nice if that could be done automatically, and depending on what platform you&#039;re using (like Linux or OS X), you could set it up to run that command every minute, or when the file changes or something.&lt;/p&gt;
&lt;p&gt;Actually, this is interesting enough that I think I&#039;ll try building this up tonight. I&#039;ll write it up on my blog when I have something to show for it.&lt;/p&gt;
</description>
 <pubDate>Fri, 23 Jun 2006 13:32:58 -0700</pubDate>
 <dc:creator>roberthahn</dc:creator>
 <guid isPermaLink="false">comment 1208 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Precompiling CSS with Extensions - A Crazy Idea?</title>
 <link>http://www.developerdotstar.com/community/node/505</link>
 <description>&lt;p&gt;I&#039;ve had this idea for a while, and I think it&#039;s a good one. I hope someone else will run with it, because I would love to have a tool that does what I&#039;ll describe. If the consensus is that it&#039;s a dumb idea, then so be it. Web developers who either don&#039;t use CSS (!) or are abstracted away from CSS by a WYSIWIG tool or development framework might not be too excited by this idea, but I suspect it will resonate with people who hand-code their CSS. My idea is for a &quot;precompiler&quot; (if that&#039;s the best label) for Cascading Style Sheets (CSS).&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/node/505&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/node/505#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/8">Web Development</category>
 <pubDate>Fri, 23 Jun 2006 07:10:59 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">505 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
