}
const Class = {
- init_lua: function() {
+ init_lua: function(optional) {
if (!this.L) {
- this.L = this.env.dispatcher.load_luabridge().create();
- this.L.set('L', proto({ write: print }, this.env));
- this.L.invoke('require', 'luci.ucodebridge');
+ let bridge = this.env.dispatcher.load_luabridge(optional);
- this.env.lua_active = true;
+ if (bridge) {
+ this.L = bridge.create();
+ this.L.set('L', proto({ write: print }, this.env));
+ this.L.invoke('require', 'luci.ucodebridge');
+
+ this.env.lua_active = true;
+ }
}
return this.L;
}
else {
try {
- let vm = this.init_lua();
- let compile = vm.get('_G', 'luci', 'ucodebridge', 'compile');
+ let vm = this.init_lua(true);
- compile.call(path);
+ if (vm)
+ vm.get('_G', 'luci', 'ucodebridge', 'compile').call(path);
+ else
+ return `Unable to compile '${path}' as Lua template: Unable to load Lua runtime`;
}
catch (lua_err) {
return `Unable to compile '${path}' as Lua template: ${format_lua_exception(lua_err)}`;