On 11/09/2010 06:57 PM, Eric Poggel wrote:
I've always felt the opposite way. It's been a while since I've worked
with Asp.net controls, but I remember something like this:

<ul id="List"></ul>
.....
// Later, in C#
for (int i=0; i<10; i++)
List.innerHtml += "<li>" + sanitize(someArray[i]) + "</li>"

While php would do something like:

<ul id="List">
<?php foreach($someArray as $item):?>
<li><?=sanitize($item)?></li>
<?php endforeach?>
</ul>

Granted, C# is a much nicer language than php, and when in php, I always
separate model and controller logic from the html view, but the
"immediate mode" of php embedding helps me avoid the awkwardness of
building html through string concatenations in another file. I get to
see the html structure exactly as it is.

This is where people usually jump in and suggest a templating system,
but I think it's silly to invent a second language when the first is
more than up to the task. I always find myself thinking: I know how to
do this in php or java, but how do I do this in the templating language?

I welcome counter-arguments. Maybe I can be enlightened?

No offense, but I don't even like the C# solution. It's still mixing the formatting with code. As I stated in a different reply in this thread, Perls Template::Recall on CPAN is the best templating solution I've found as it completely separates the template from the code. Also, it's not tied to just HTML/XML, so it can be used for a variety of purposes. Lastly, by having the separation of code and template, one person can be responsible for designing the HTML for the web page while another can populate the HTML. If the HTML changes, it can be done in a way that the code does not change.

Casey

Reply via email to