diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-09 08:23:11 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-09 08:23:11 +0200 |
commit | 99594791e0c34aee3659370b8c2072df815c9051 (patch) | |
tree | 5a523d3cbd3aec55a9bbf97beda7bff7605e9b62 /theme/javascript/utils/execute.js | |
parent | 1b432288f041baef2ebe54c96a7a86f547b14c67 (diff) | |
parent | 2cc23b7e3411e1748bc8a25114a7bf9185a210f1 (diff) | |
download | gitbook-99594791e0c34aee3659370b8c2072df815c9051.zip gitbook-99594791e0c34aee3659370b8c2072df815c9051.tar.gz gitbook-99594791e0c34aee3659370b8c2072df815c9051.tar.bz2 |
Merge Optional github
Diffstat (limited to 'theme/javascript/utils/execute.js')
-rw-r--r-- | theme/javascript/utils/execute.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/theme/javascript/utils/execute.js b/theme/javascript/utils/execute.js index 76033f6..eb2a19b 100644 --- a/theme/javascript/utils/execute.js +++ b/theme/javascript/utils/execute.js @@ -71,13 +71,21 @@ define([ repl.loadLanguage(lang.id, eventHandler); }; - var execute = function(lang, solution, validation, callback) { + var execute = function(lang, solution, validation, context, callback) { + // Language data + var langd = LANGUAGES[lang]; + // Check language is supported - if (!LANGUAGES[lang]) return callback(new Error("Language '"+lang+"' not available for execution")); + if (!langd) return callback(new Error("Language '"+lang+"' not available for execution")); // Validate with validation code - var code = [solution, LANGUAGES[lang].assertCode, validation].join(";\n"); - evalJS(LANGUAGES[lang], code, function(err, res) { + var code = [ + context, + solution, + langd.assertCode, + validation, + ].join(langd.sep); + evalJS(langd, code, function(err, res) { if(err) return callback(err); if (res.type == "error") callback(new Error(res.value)); @@ -86,4 +94,4 @@ define([ }; return execute; -});
\ No newline at end of file +}); |