Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML?
Still needs: Context-sensitive escaping, css generation, javascript inclusion.
Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML?
Still needs: Context-sensitive escaping, css generation, javascript inclusion.
(Sorry; pet peeve. ;))
Developers should write HTML for the same reason that business people should learn to edit HTML--it's the best canonical format for all stakeholders.
I found this interesting. I've been doing web stuff since 1996, and I would have agreed with you back then. But these days my perception is that the majority of stuff on the web should be considered to be applications rather than documents.
$table = new Sprocket( 'table' );
$tr = $table->tr();
$tr->td( "OMG I'm in a sprocket" );
I've done similar things using XElement in C#, though using PHP's magic methods makes for very short readable code.
I agree that templates are handy for separation of concerns though.
Templates can be incredibly simple and require no further attention, but even slightly more complex ones like Smarty work really well, in my experience.
I agree that virtually no designers will be able to work directly with something like Markaby; but then, nobody asks them to. They hand the designer the unstyled output of Markaby.
First it's overkill. The reason we have a www at all is because HTML and its variants are dead simple. If the client decides that six key sentences should be yellow and emphasized, I go into my template and add a <span class="yellow"><em>Yellow text!</em></span> to my template.
Using your generator, I now have to figure out a whole new way of doing that.
The second point follows: Any first year web monkey can learn to add spans and em's. It takes a bit more effort to understand python. While this might not matter to someone who understands both, it offers much less flexibility to the already available alternative.
Django's template implementation is very, very good. It fits quite well into your average web shop and even fails silently.
I like your desire to scratch your own itch, but I felt I should answer your question.
<span class="client_wants_yellow_client_gets_yellow">Yellow!</span>CSS classes should be used sparingly and by purpose: they should describe the function of the element, and not the look of the element.
But that's just semantics ;) (har, har).
ASP.net uses code generated html for a lot of things: server controls, some user controls, and so forth. It can be a pain to override them if the markup they generate is crap (and from my experience, the built-in server controls and many of the 3rd party controls generate crap).
Not calling it yellow I think is the more important piece. In fact class="sctmtdt" seems best to me.
* (Stupid Client Told Me To Do This) :-)