UNPKG

@communities-webruntime/services

Version:

If you would like to run Lightning Web Runtime without the CLI, we expose some of our programmatic APIs available in Node.js. If you're looking for the CLI documentation [you can find that here](https://www.npmjs.com/package/@communities-webruntime/cli).

48 lines 1.81 kB
"use strict"; /** @hidden */ /** * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ const pretty = require('pretty'); const { component } = require('../template-generators/template-utils'); const { generateAttributesJS, DEFAULT_ATTRIBUTES } = require('./attributes-js-generator'); /** * Generate an LWC template for a provided component * * @param {object*} cmp - The top level component to render an LWC template for * @param {boolean} isThemeLayout - Whether that component is a theme layout or not */ function template(cmp, isThemeLayout, isRenderDesignMode = false) { const result = component({ cmp, isThemeLayout, regionName: null, regionKey: null, attributeSet: {}, isTopLevel: true, isRenderDesignMode, }); const attributesVal = generateAttributesJS(result.attributes.attributes); return { html: pretty(`<template>${result.html}</template>`, { ocd: true }), attributes: attributesVal, }; } /** * Generates javascript which imports an HTML file and exports the HTML as default * * @param {string} moduleName - The name of the view, used to specify the import location of the HTML * @param {string} attributesVal - The attribute set value of the view, used to inject component attribute values during runtime */ function javascript(moduleName, attributesVal) { return `import html from './${moduleName}.html' export default { "html": html, "attributes": ${attributesVal || DEFAULT_ATTRIBUTES} }`; } module.exports = { template, javascript, generateAttributesJS }; //# sourceMappingURL=view-template-generator.js.map