@dooboostore/dom-render
Version:
html view template engine
50 lines • 2.7 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { ScriptUtils } from '@dooboostore/core-web/script/ScriptUtils';
export var ExecuteState;
(function (ExecuteState) {
ExecuteState[ExecuteState["EXECUTE"] = 0] = "EXECUTE";
ExecuteState[ExecuteState["NO_EXECUTE"] = 1] = "NO_EXECUTE";
ExecuteState[ExecuteState["STOP"] = 2] = "STOP";
})(ExecuteState || (ExecuteState = {}));
export class OperatorExecuter {
constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack, startingExecute = true) {
this.rawSet = rawSet;
this.render = render;
this.returnContainer = returnContainer;
this.elementSource = elementSource;
this.source = source;
this.afterCallBack = afterCallBack;
this.startingExecute = startingExecute;
}
;
start() {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f;
let attrValue = this.elementSource.attr;
// console.log('OperatorExecuter ', attrValue, this);
if ((_a = this.source.operatorAround) === null || _a === void 0 ? void 0 : _a.beforeAttr) {
attrValue = (_b = this.source.operatorAround.beforeAttr(attrValue, this)) !== null && _b !== void 0 ? _b : '';
}
let r = attrValue;
if (r && this.startingExecute) {
r = ScriptUtils.eval(` ${this.render.bindScript}; return ${attrValue}`, Object.assign(this.source.obj, { __render: this.render }));
}
if ((_c = this.source.operatorAround) === null || _c === void 0 ? void 0 : _c.before) {
r = (_d = this.source.operatorAround) === null || _d === void 0 ? void 0 : _d.before(r, this);
}
const state = yield this.execute(r);
(_f = (_e = this.source.operatorAround) === null || _e === void 0 ? void 0 : _e.after) === null || _f === void 0 ? void 0 : _f.call(_e, r, this);
return state;
});
}
;
}
//# sourceMappingURL=OperatorExecuter.js.map