Refactor out load_extensions_from_config function

This commit is contained in:
Thomas Kluyver 2014-12-17 16:41:26 -08:00
parent 53d1f1b1a1
commit c719d2fe83
2 changed files with 16 additions and 7 deletions

View File

@ -39,6 +39,20 @@ define([
);
};
/**
* Wait for a config section to load, and then load the extensions specified
* in a 'load_extensions' key inside it.
*/
function load_extensions_from_config(section) {
section.loaded.then(function() {
if (section.data.load_extensions) {
var nbextension_paths = Object.getOwnPropertyNames(
section.data.load_extensions);
IPython.load_extensions.apply(this, nbextension_paths);
}
});
}
//============================================================================
// Cross-browser RegEx Split
//============================================================================
@ -822,6 +836,7 @@ define([
};
var utils = {
load_extensions_from_config: load_extensions_from_config,
regex_split : regex_split,
uuid : uuid,
fixConsole : fixConsole,

View File

@ -150,13 +150,7 @@ require([
IPython.tooltip = notebook.tooltip;
events.trigger('app_initialized.NotebookApp');
config_section.loaded.then(function() {
if (config_section.data.load_extensions) {
var nbextension_paths = Object.getOwnPropertyNames(
config_section.data.load_extensions);
IPython.load_extensions.apply(this, nbextension_paths);
}
});
utils.load_extensions_from_config(config_section);
notebook.load_notebook(common_options.notebook_path);
});