On 2010-11-10 00:57, Eric Poggel wrote:
On 11/9/2010 12:17 AM, Nick Sabalausky wrote:
"Andrei Alexandrescu"<seewebsiteforem...@erdani.org> wrote in message
news:ibaepi$vf...@digitalmars.com...

People at Facebook told me that the adoption of D inside the company
might
be helped if they could simply write<?d ... ?> to insert D code into a
page. I'm not sure how difficult such a plugin would be to implement.

I'm very suprised by that. That's become considered very bad style by
most
of the [professional] web dev world quite awhile ago, and for very good
reason. Rails-, django- and even ASP.NET-style "pass variables into an
HTML
template" approaches have proven to be...well...frankly, much less
shitty.



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>

I would as well. I don't think it's wrong adding a some code to the views to help write HTML, the example above is a perfect example.

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?

Isn't a PHP kind of a template system? It's created for web development and to be able to mix HTML and PHP out of the box.

--
/Jacob Carlborg

Reply via email to