Client-side DOM-based templating; declarative front-end UI; intuitively -- "reverse jQuery".
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

dollar-gee ($g)

A little routine for declarative UI definition (or basically creating DOM nodes.)

  • $g('xxx') is the same as parsing <div class='xxx'></div>
  • $g('', 'xxx') will be a text element xxx
  • $g('.a', { href: 'link' }, 'the link') will be an <a> element with a text element inside: <a href='link'>the link</a>
  • $g('#div1', [ $g('#div2 xxx', 'in div2'), $g('#div3 yyy', 'in div3'), 'in div1' ]) will output

    in div2
    in div3
    in div1

    For a bit more complex example, look inside the source. I used this little thing to create UI tree for an iGoogle app back in the day.