News for hackers. Stuff that matters.
Re:Idea: using code rather than templates to generate HTML by cosmo7 on Tuesday April 14, 2009 @02:43PM (#562016)
My project, phpSprockets (http://code.google.com/p/phpsprockets/) does nested markup by working as a node system. After all, if you're going to generate HTML in code you might as well do it in an object oriented way.

$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.

There are no comments on this comment yet.