@raintech-oss/jovo-dew
Version:
Dew View Engine for Jovo
26 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ViewVariablesProcessor = void 0;
const BaseProcessor_1 = require("./BaseProcessor");
class ViewVariablesProcessor extends BaseProcessor_1.BaseProcessor {
constructor(plugin, jovo) {
super(plugin, jovo);
this.plugin = plugin;
this.jovo = jovo;
}
process(key, obj, viewPath, data) {
// console.log({ key, obj, viewPath });
if (!this.plugin.config.viewVariables) {
throw new Error(`No viewVariables configured for 'DewViewEnginePlugin'`);
}
const funcName = this.jovo.$t(`${viewPath}.${key}`, data);
const func = this.plugin.viewVariables[funcName];
if (func) {
const value = func.call(this.plugin.viewVariables);
return value;
}
return { error: `[missing '${funcName}()' function in ViewVariables]` };
}
}
exports.ViewVariablesProcessor = ViewVariablesProcessor;
//# sourceMappingURL=ViewVariablesProcessor.js.map