UNPKG

kdesign-ui

Version:

kd is from company of klx, it provide quickly genarator company inner business front structure

79 lines (78 loc) 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GenerateStyle = exports.GenerateJs = exports.GenerateTpl = void 0; var tslib_1 = require("tslib"); var CRLF = '\n'; var INDENT = '\u0020\u0020'; var GeneraeBase = /** @class */ (function () { function GeneraeBase() { this.CRLF = CRLF; this.INDENT = INDENT; this.CODE = ''; this.STARTCODE = ''; this.ENDCODE = ''; } GeneraeBase.prototype.composeCode = function (CODE) { return (this.STARTCODE + this.CRLF + this.INDENT + CODE + this.CRLF + this.ENDCODE + this.CRLF); }; GeneraeBase.prototype.baseGenerate = function (name, props, visitor) { var STARTTAG = "<" + name; var closeTag = '>'; props = Object.assign({}, props); visitor.before && visitor.before(name, props); for (var key in props) { if (props.hasOwnProperty(key)) { var isString = this.isString(props[key]); visitor.executing && visitor.executing(isString, props, key); STARTTAG += this.CRLF + this.INDENT; STARTTAG += "" + (isString ? '' : ':') + key + "='" + (isString ? props[key] : key) + "'"; } } STARTTAG += closeTag; STARTTAG += this.CRLF + this.INDENT; STARTTAG = (visitor.after && visitor.after(STARTTAG)) || STARTTAG; STARTTAG += "</" + name + ">"; return STARTTAG; }; GeneraeBase.prototype.isString = function (val) { return typeof val === 'string'; }; return GeneraeBase; }()); //基础模板类 var GenerateTpl = /** @class */ (function (_super) { tslib_1.__extends(GenerateTpl, _super); function GenerateTpl() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.STARTCODE = "<template>"; _this.ENDCODE = "</template>"; _this.COMPOSE = {}; return _this; } return GenerateTpl; }(GeneraeBase)); exports.GenerateTpl = GenerateTpl; //基础脚本类 var GenerateJs = /** @class */ (function (_super) { tslib_1.__extends(GenerateJs, _super); function GenerateJs() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.STARTCODE = "<script>"; _this.ENDCODE = "</script>"; return _this; } return GenerateJs; }(GeneraeBase)); exports.GenerateJs = GenerateJs; //基础样式类 var GenerateStyle = /** @class */ (function (_super) { tslib_1.__extends(GenerateStyle, _super); function GenerateStyle() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.STARTCODE = "<style>"; _this.ENDCODE = "</style>"; return _this; } return GenerateStyle; }(GeneraeBase)); exports.GenerateStyle = GenerateStyle;