Created
May 17, 2013 15:43
-
-
Save Heavyblade/5599929 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
| var Engine = { | |
| json: function(jsonresp, wapp) { | |
| var jsonp = wapp.router.params.callback; | |
| jsonresp = jsonp ? (jsonp + "(" + JSON.stringify(jsonresp) + ")") : JSON.stringify(jsonresp); | |
| jsonresp = unescape(encodeURIComponent(jsonresp)); // Encode to UFT-8 | |
| var headers = [("Content-Type: application/" + (jsonp ? "javascript" : "json") + "; charset=utf-8")] | |
| return({body: jsonresp, headers: headers}); | |
| }, | |
| html: function(jsonresp, wapp, controller, action) { | |
| var file = "views/" + controller.replace("Controller", "") + "/" + action | |
| var pureHTML = getHTML(file); | |
| var body = pureHTML.type == "template" ? Handlebars.compile(pureHTML.html)(jsonresp) : pureHTML.html | |
| var headers = ["Content-Type: text/html; charset=utf-8"]; | |
| return({body: body, headers: headers}); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment