Fog Creek Software
Discussion Board




Perfectionism

Joel wrote:
"I could go insane with the web page behind the discussion board. First I could make it 110% xhtml 1.1 + CSS. Heck, why not xhtml 2.0 just to be extra addictive-personality-disordered. Then I could neatly format all the html code so it's perfectly indented. But the html is generated by a script, and the script has to be indented correctly so that it's perfect too, and a correctly indented ASP script does not, by defintion, produce correctly indented HTML. So I could write a filter that takes the output of the ASP script and reindents it so that if anybody does a View Source they would see neatly indented HTML and think I have great attention to detail. Then I would start to obsess about all the wasted bandwidth caused by meaningless whitespace in the HTML file, and I'd go back and forth in circles between compressed HTML and nicely laid out HTML, pausing only to shave."

As far as neatly formatted HTML+code and stripping whitespace goes, this can all be accomplished using a template system.  If you were using PHP, for example, all of the above could be done for you using the Smarty template system ( http://smarty.php.net ).  Correctly format your HTML, have it nicely indented, and automatically strip out white space before it is sent over the network.  No mixing of code with HTML.  Send the template over to your graphic designer so they can format it any way you want - or even create multiple formats for your users to select from.  ;)  I thought templates were B.S. until I started to use them.  Everything is so pretty now. :)  Super easy too.

I dont know if there are any template systems for ASP though.  Perhaps someone else can enlighten us if there is.

Paul Baranowski
Monday, May 17, 2004

Well, I hate to see this flounder. I wonder if a thread could be started on using templating systems (not to go to MVC). In Perl I used HTML::Template and then Template::Toolkit and in PHP I also use smarty. I work with 3-5 other programmers and I'm the only one using a templating system which means I rarely get to use it except when no one is looking or when I control the project. We use a CMS system and it was my job to maintain, grow it as the primary developer looked into Java solutions. In a few places I used smarty. The code has globals everywhere, files included all over the place and more if statements than anything else. As a user of templates I'm accustomed to building up a data model and then passing that to the template system. My code NEVER prints (even debug info is stored and printed at the end). I began changing the code by building data models which represented the users and their attributes (one form has 89 different views owing to users' permissions/roles), and anything else ... all arrays of arrays ... and then I have an engine which builds the output so 85% the time a change is only needed in the data model. The engine is well organized so if it needs to change it's easy to do so (but it rarely does).

But ... personally what I like about template systems is that people should or ought to think about what they are doing before they do it.  I've worked on a LoT of code written by other people but I've never seen this system of just building up a data model.

me
Monday, May 17, 2004

I use smarty to do my kids homework as well, it provides nicely laid out templates of all the answers and properly indents the important bits.


thanks smarty!  you are the best.

FullNameRequired
Monday, May 17, 2004

smartys the best all right.  I use it to control my ride-on lawnmower, it provides the template of the lawn shape *and* correctly indents the edges.



thanks smarty!

I hate marketers
Monday, May 17, 2004

*  Recent Topics

*  Fog Creek Home