-
Notifications
You must be signed in to change notification settings - Fork 27
User made plugins
azproduction edited this page Jan 28, 2013
·
1 revision
You can create your own plugin for your needs.
Start with this code:
(function (sb) {
sb.require.user_plugin_feature = function () {
return 'Hello from user plugin!';
};
}(sandbox));
Important thing - you have to wrap your plugin with IIFE.
Put your plugin somshere and declate it in the .lmd.json config file:
{
"root": "../",
"output": "index.lmd.js",
"modules": {
"main": "js/main.js"
},
"main": "main",
"plugins": {
"user_plugin": "plugins/user_plugin.js"
}
}
If your plugin required some config you may provede them to your plugin.
{
"root": "../",
"output": "index.lmd.js",
"modules": {
"main": "js/main.js"
},
"main": "main",
"plugins": {
"user_plugin": {
"path": "plugins/user_plugin.js",
"options": {
"pewpew": "ololo"
}
}
}
}
Plugin with config
(function (sb) {
sb.require.user_plugin_feature = function () {
return sb.options.user_plugin; // {"pewpew": "ololo"}
};
}(sandbox));
You may also listen to all plugins events. See List of internal LMD events
See aster/examples/plugins/user_plugins for example