Skip to content

Instantly share code, notes, and snippets.

@shaunxcode
Created June 14, 2012 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunxcode/2929101 to your computer and use it in GitHub Desktop.
Save shaunxcode/2929101 to your computer and use it in GitHub Desktop.
quick coffeescript jquery dsl
String.prototype.$tag = (args...) ->
args.unshift "<#{@toString()}/>"
$.apply window, args
("ul".$tag
class: "someUL"
html: "li".$tag
text: "some text in an li"
class: "some class"
click: ->
console.log "some click event").appendTo 'body'
#yields <ul class="someUL"><li class="some class">some text in an li</li></ul>
#appended to the body w/ a click event bound to the li.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment