Skip to content

Instantly share code, notes, and snippets.

@honza
Created July 31, 2015 13:30
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 honza/7c7305b09b2be0753250 to your computer and use it in GitHub Desktop.
Save honza/7c7305b09b2be0753250 to your computer and use it in GitHub Desktop.
// Given
var content = {
id: 1,
name: 'Honza'
};
function renderTemplate(content) {
return 'Hello, ' + content.name;
}
// Which of the following functions is simpler?
function render1(content) {
return renderTemplate(content);
}
function render2(contentId, callback) {
ajax({
url: '/api/2/content/' + contentId + '/',
method: 'GET',
success: function(content) {
var rendered = renderTemplate(content);
callback({
status: 'ok',
output: rendered
});
},
error: function(){
callback({
status: 'error',
output: null
})
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment