UNPKG

@awesome-fe/translate

Version:
30 lines 1.35 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.htmlTagVisitor = void 0; function htmlTagVisitor(node) { var _a, _b; var attributes = Object.entries((_a = node === null || node === void 0 ? void 0 : node.attributes) !== null && _a !== void 0 ? _a : {}) .map(function (_a) { var key = _a[0], value = _a[1]; return "".concat(key, "=\"").concat(value, "\""); }); var attrText = __spreadArray([''], attributes, true).join(' '); if (node.selfClosing || node.type === 'br') { return "<".concat(node.tagName).concat(attrText, " />"); } else { var content = (_b = node.content) !== null && _b !== void 0 ? _b : this.all(node).join('\n\n'); return ["<".concat(node.tagName).concat(attrText, ">"), content, "</".concat(node.tagName, ">")].join(node.block ? '\n' : ''); } } exports.htmlTagVisitor = htmlTagVisitor; //# sourceMappingURL=html-tag-visitor.js.map