UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

38 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContentForPlayground = getContentForPlayground; const ts_morph_1 = require("ts-morph"); /** * * @param expression * @param playgroundId * @param playground */ function getContentForPlayground(playground) { const content = playground.getProperty('content'); if (ts_morph_1.Node.isPropertyAssignment(content)) { const contentInitializer = content.getInitializer(); if (ts_morph_1.Node.isObjectLiteralExpression(contentInitializer)) { return contentInitializer .getProperties() .reduce((content, property) => { if (ts_morph_1.Node.isPropertyAssignment(property)) { const initializer = property.getInitializer(); if (ts_morph_1.Node.isObjectLiteralExpression(initializer)) { const templateProperty = initializer.getProperty('template'); if (ts_morph_1.Node.isPropertyAssignment(templateProperty)) { const templateInitializer = templateProperty.getInitializer(); if (ts_morph_1.Node.isStringLiteral(templateInitializer) || ts_morph_1.Node.isNoSubstitutionTemplateLiteral(templateInitializer)) { content[property.getName()] = templateInitializer.getLiteralValue(); } } } } return content; }, {}); } } return {}; } //# sourceMappingURL=get-content-for-playground.js.map