From 88949d39ce4dc8c385ac1022a247e0de861e7b3a Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 24 Oct 2022 23:40:22 -0500 Subject: [PATCH] Undo template gen removal during deprecation property removal --- .../src/client/angular-beta/StorybookModule.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts b/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts index 7bc401b66c54..5403a3ecbea0 100644 --- a/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts +++ b/code/frameworks/angular/src/client/angular-beta/StorybookModule.ts @@ -7,6 +7,7 @@ import { storyPropsProvider } from './StorybookProvider'; import { isComponentAlreadyDeclaredInModules } from './utils/NgModulesAnalyzer'; import { isDeclarable, isStandaloneComponent } from './utils/NgComponentAnalyzer'; import { createStorybookWrapperComponent } from './StorybookWrapperComponent'; +import { computesTemplateFromComponent } from './ComputesTemplateFromComponent'; export const getStorybookModuleMetadata = ( { @@ -21,7 +22,12 @@ export const getStorybookModuleMetadata = ( storyProps$: Subject ): NgModule => { const { props, styles, moduleMetadata = {} } = storyFnAngular; - const { template } = storyFnAngular; + let { template } = storyFnAngular; + + const hasTemplate = !hasNoTemplate(template); + if (!hasTemplate && component) { + template = computesTemplateFromComponent(component, props, ''); + } /** * Create a component that wraps generated template and gives it props @@ -68,3 +74,7 @@ export const createStorybookModule = (ngModule: NgModule): Type => { class StorybookModule {} return StorybookModule; }; + +function hasNoTemplate(template: string | null | undefined): template is undefined { + return template === null || template === undefined; +}