Created
July 31, 2015 13:30
-
-
Save honza/7c7305b09b2be0753250 to your computer and use it in GitHub Desktop.
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
// 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