Skip to content

Commit b9267e8

Browse files
committed
Component generator
1 parent cb67fcd commit b9267e8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/react-sdk/src/component-generator.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {
1414
transpileExpression,
1515
} from "@webstudio-is/sdk";
1616
import { indexAttribute, isAttributeNameSafe, showAttribute } from "./props";
17-
import { collectionComponent, descendantComponent } from "./core-components";
17+
import {
18+
blockComponent,
19+
blockTemplateComponent,
20+
collectionComponent,
21+
descendantComponent,
22+
} from "./core-components";
1823
import type { IndexesWithinAncestors } from "./instance-utils";
1924

2025
/**
@@ -231,6 +236,10 @@ export const generateJsxElement = ({
231236
}
232237

233238
let generatedElement = "";
239+
if (instance.component === blockTemplateComponent) {
240+
return "";
241+
}
242+
234243
if (instance.component === collectionComponent) {
235244
// prevent generating invalid collection
236245
if (
@@ -246,6 +255,10 @@ export const generateJsxElement = ({
246255
generatedElement += children;
247256
generatedElement += `</Fragment>\n`;
248257
generatedElement += `)}\n`;
258+
} else if (instance.component === blockComponent) {
259+
if (instance.children.length > 1) {
260+
generatedElement += children;
261+
}
249262
} else {
250263
const [_namespace, shortName] = parseComponentName(instance.component);
251264
const componentVariable = scope.getName(instance.component, shortName);

0 commit comments

Comments
 (0)