In a component, a variable declared in its <script server> block is visible to interpolation (including inside an attribute) but not to an @if in the same component's template: the @if behaves as if the variable were undefined.
<script server>
const signedIn = !!requestContext.cookie('auth-token')
</script>
<header data-state="">
@if (!signedIn)
<a href="/login">Sign in</a>
@endif
</header>With cookie: auth-token=x the attribute renders true, and the link is still rendered. Without the cookie the attribute renders false and the link is rendered, so the @if is never false. Moving the condition into a class (class="") works, so the value is there at render time.
Expected: the same scope for both, or a diagnostic when @if names an undefined variable. stx 0.2.756, found in resources/components/SiteHeader.stx of the Settlers III remake.