How To Dynamic Web Rendering?

Adam D. Ruppe destructionator at gmail.com
Mon May 16 07:15:00 PDT 2011


Jacob Carlborg wrote:
> I think you really should give it a try. This is a good place to start:

Cool, thanks!

> Don't know why but I think this is verbose and it's more difficult
> to visualize how the HTML will look like.

That's also a bizarre example... 9/10 times, my code looks more like:

auto list = document.getElementById("items-holder");
foreach(item; items)
    list.addChild("li", item);

than the longer thing. If you want to visualize the html, you
usually want to look at the html file, since it contains the
majority of the structure.

> but usually you use the "form_for" or "form_tag" helper that
> Rails provides:

That's not bad.

> Another thing I really like is it's built in support for
> rebinding the "this" variable

That's easy in Javascript too. It has the Function.apply method
built in that makes it as simple as writing a higher order function.

I find javascript is easier to use if you think of it as a
functional language with procedural elements rather than an object
oriented one.

> Correct me if I'm wrong but that would require a request for
> bascially every function call?

Most of them, yes (though calls being passed as arguments to other
calls are combined0, but keep in mind a HTTP request does *not* have
to go to the server! If your server side code gives the appropriate
cache headers, the ajax responses are cached too.

There's a good chance you have to hit the server anyway for db
access too...

> I don't like that, and I don't like the inline javascript.

Inline javascript was done here for convenience. You're
free to do it in a separate file just like any other script.


More information about the Digitalmars-d-learn mailing list