Created
February 14, 2011 18:51
-
-
Save arkitrave/826338 to your computer and use it in GitHub Desktop.
Comparison of templated vs. non-templated HTML rendering
This file contains 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
// Rendering markup with loops and string concatenation | |
for (var i = 0; i < foo.name.length; i++) { | |
content += '<li><a href="foo/' + foo.id[i] + '">' + foo.name[i] + '</a></li>'; | |
} | |
// Rendering with a JavaScript template | |
content = '{{#foo}}' + | |
'<li><a href="foo/${id}">${name}</a></li>' + | |
'{{/foo}}'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment