Writing code which looks nice is a learned skill, not difficult in its own right, but requiring time and effort to master.
Writing Code generating code such that both the generating code and the generated code look nice is far more difficult.
Okay, in the case at hand, both parts barely qualify as code. I am using PHP code and the Savant2 template engine to generate XHTML. Making the PHP code look nice is relatively easy and fairly independent of the other two pieces. Making the template code (also PHP) look nice whilst generating XHTML that looks nice is quite a chore. I feel like I'm spending too much time getting all of the XHTML to look nice, but I hate debugging stuff that spews a pile of undifferentiated line noise. Actually, I suppose the rendered XHTML also has to look nice, but that's sort of a given.