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/expressions.tsmodified+8-3
Changes to packages/stx/src/expressions.ts
@@ -640,7 +640,7 @@ export function interpolateScriptsInTemplate(
640640/**
641641 * Process template expressions including variables, filters, and operations
642642 */
643export function processExpressions(template: string, context: Record<string, any>, filePath: string): string {
643export function processExpressions(template: string, context: Record<string, any>, filePath: string, options?: { forceSignals?: boolean }): string {
644644 let output = template
645645
646646 // Protect <style> and <script> blocks that contain NO stx template
@@ -677,8 +677,13 @@ export function processExpressions(template: string, context: Record<string, any
677677 output = maskInto(output, matchScriptElement, scriptBlocks, n => `<!--__STX_SCRIPT_EXPR_${n}__-->`)
678678
679679 // Check if this template uses signals - if so, we need to preserve expressions
680 // that reference runtime variables (like loop variables or signal calls)
681 const hasSignals = usesSignalsInScript(template)
680 // that reference runtime variables (like loop variables or signal calls).
681 // `forceSignals` is set by the @include path: a partial's <script> is stripped
682 // (includes.ts) before this runs, so usesSignalsInScript(template) can't see its
683 // own state()/derived(). The caller computes the gate on the partial's FULL
684 // content and passes it here, so {⁠{ }} over the partial's own signals are
685 // preserved for the runtime — exactly like a top-level page. See stacksjs/stx#1758.
686 const hasSignals = options?.forceSignals === true || usesSignalsInScript(template)
682687
683688 // Replace triple curly braces with unescaped expressions {⁠{⁠{ expr }}} - similar to {⁠!! expr !!}
684689 output = output.replace(/\{\{\{([\s\S]*?)\}\}\}/g, (match, expr, offset) => {