D to Javascript converter (a hacked up dmd)

Andrea Fontana advmail at katamail.com
Mon Feb 27 08:44:54 PST 2012


Il giorno lun, 27/02/2012 alle 16.55 +0100, Adam D. Ruppe ha scritto:

> On Monday, 27 February 2012 at 15:39:50 UTC, Andrea Fontana wrote:
> > About jquery: i mean what about a d function similar to  $() 
> > jquery
> > function for better elements handling (instead of 
> > getElementById() )
> 
> Have you seen my dom library? :P


Of course not!


> It's all server side but it is just awesome. Lots of
> convenience functions, getting elements is easy, and
> operating on them as a group is too, either through
> a wrapper struct or just using foreach yourself.
> 
> I definitely want to port some of it to the javascript
> output.
> 
> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
> the file is dom.d. It also depends on characterencodings.d.
> 
> The most jquery-like interface is Document's opIndex:
> 
> document[`#something .my-thing > p`].addClass("matched")
>    .appendText("matched me!");
> 
> 
> Though, I really think that querySelectorAll + foreach
> wipes out jquery's element selection advantage.
> 
> querySelectorAll is in all browsers IE8 and up. Adding
> foreach to javascript can be done with text macro
> (see html.d in my github) or D->JS of course has foreach
> too!
> 
> 
> The zip of d->js actually breaks on foreach here, but
> it was an easy fix. I'll push up the changes this next
> weekend.
> 
> 
> Anyway, here's how it looks:
> 
> foreach(element; document.querySelectorAll("#blah > p"))
>      // do something to element
> 


Very interesting! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20120227/c8cabefd/attachment-0001.html>


More information about the Digitalmars-d-announce mailing list