Created
November 17, 2009 13:09
-
-
Save quackingduck/236893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FancyDomBuilder: | |
$.fn.n = function(builder) { | |
var self = this; | |
builder(function(str) { return $(str).appendTo(self) }); | |
return self; | |
}; | |
// with FancyDomBuilder: | |
$('%div.person').n(function(n) { | |
n('%span.name').n(function(n) { | |
n('%span.first').text(first); | |
n('%span.last').text(last); | |
}); | |
n('%span.phone').text(person.phone); | |
}); | |
// normal jquery: | |
$('%div.person'). | |
append( | |
$('%span.name'). | |
append($('%span.name').text(person.name)). | |
append($('%span.name').text(person.last)) | |
). | |
append($('%span.phone').text(person.phone)); | |
// or Mustache/Mojo: | |
<div class="person"> | |
<span class="name"> | |
<span class="first">{ first }</span> | |
<span class="last">{ last }</span> | |
</span> | |
<span class="phone">{ phone }</span> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment