Hello!
I would like to shamelessly announce here an alternative library to
manipulate web page contents: Silk.
Not yet in bower (as I don't know whether I should do it myself or under
amber-smalltalk, so not registering, as there is no unregister in
bower), but it is possible to get it into your project via:
bower install git://github.com/herby/silk --save
It does not have any dependency (except amber library domite that it
builds upon; but no external one).
The metaphor it heavily builds upon is: each element is a Stream of its
children, you can write to that stream, copy that stream to get the copy
of the "cursor" etc. It contains only one class Silk, which represent
DOM node _both_ as an element (that can be inserted) and as a stream
(which can insert things into itself).
The main message there is <<, the high-level putting an object on a
stream. Silk new conveniently wraps body and put the cursor at the end.
So, by
Silk new << 'Hello, world!'
you append a text node into a body.
It uses browser support for querySelector to get to elements - that is,
you can do all the basic things, but not all the fancy stuff (:visible)
that only jQuery has. So, you can
'#log' asSilk << 'another item'
to append a text.
Silk uses DNU to help you create elements, and uses associations as a
way to set attributes. This should be self-explanatory:
Silk new
H1: {'id'->'header'. 'Welcome'};
P: {'id'->'welcome'. 'This is an acme page.'. 'It was created by Silk'};
HR;
SMALL: {'id'->'footer'. 'We do not guarantee anything.'}
BTW, `foo H1: bar` is just a convenience for `foo H1 << bar; yourself`.
You can use blocks, if you << them (or include them in TAGNAME:), they
are called and passed the wrapped element stream in the first parameter.
As for widgets, any object will work, it only needs renderInSilk: aSilk
method present. If you aSilk << suchObject, its renderInSilk: will be
called (that's how association and block magic is done).
I probably did not cover everything, but this is basics, and the code is
so small I presume you can get it anyway.
I would like to hear how you feel when playing with it.
Herby
--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[hidden email].
For more options, visit
https://groups.google.com/d/optout.