ReviewOS

also looking at this

stacks/stx

fix(includes): preserve {⁠{ }} in @include partials that define their own signals (#1758)

#1759
Merged glennmichael123 wants to merge fix/1758-mustache-in-include-partials into main
3 files +76 -6
packages/stx/src/includes.tsmodified+12-3
Changes to packages/stx/src/includes.ts
@@ -69,7 +69,7 @@
6969import type { StxOptions } from './types'
7070import path from 'node:path'
7171import { processConditionals } from './conditionals'
72import { processExpressions } from './expressions'
72import { processExpressions, usesSignalsInScript } from './expressions'
7373import { LRUCache } from './performance-utils'
7474import { createSafeFunction, isExpressionSafe, safeEvaluate, safeEvaluateObject } from './safe-evaluator'
7575import { transformStoreImports } from './store-imports'
@@ -1103,8 +1103,17 @@ catch (e) {
11031103 // Process conditionals
11041104 processedContent = processConditionals(processedContent, includeContext, includeFilePath)
11051105
1106 // Process expressions
1107 processedContent = processExpressions(processedContent, includeContext, includeFilePath)
1106 // Process expressions.
1107 // The partial's <script> was stripped above (line ~925) so the style/script
1108 // extractors and the parent's client-script pipeline don't double-process it.
1109 // That also hides the partial's own state()/derived() from processExpressions'
1110 // usesSignalsInScript gate, which would then evaluate `{⁠{ signalCall() }}`
1111 // server-side (undefined → emptied) and consume the marker, leaving nothing
1112 // for the runtime to bind — the partial renders permanently blank. Recover the
1113 // gate from the FULL partial content so a partial with a client signal script
1114 // preserves {⁠{ }} just like a top-level page. See stacksjs/stx#1758.
1115 const partialHasSignals = usesSignalsInScript(partialContent)
1116 processedContent = processExpressions(processedContent, includeContext, includeFilePath, { forceSignals: partialHasSignals })
11081117
11091118 // Append preserved style and script for SFC support
11101119 if (preservedStyle) {