Curvea

CurveaScript

Conditionals

CurveaScript supports build-time conditionals with:

@if
@elseif
@else
@end

Basic conditional

@if page.title
  <h1>{{ page.title }}</h1>
@end

If the expression resolves to a truthy value, the block is rendered.

Else block

@if page.title
  <h1>{{ page.title }}</h1>
@else
  <h1>Untitled</h1>
@end

Else-if block

@if page.type == "post"
  <p>Post</p>
@elseif page.type == "page"
  <p>Page</p>
@else
  <p>Other</p>
@end

Supported comparisons

The current condition evaluator supports:

==
!=
>
<
>=
<=

Examples:

@if product.price > 100
  <p>Premium</p>
@end
@if page.draft != true
  <p>Published</p>
@end

Supported values

Condition values can be:

  • quoted strings
  • numbers
  • true
  • false
  • null
  • simple path expressions

Nested blocks

Conditionals may contain nested @if or @for blocks.

@if collection.items
  @for item in collection.items
    <p>{{ item.title }}</p>
  @end
@end

Limitations

Conditions are not JavaScript.

Unsupported:

@if items.length > 0

This only works if items.length exists as a value in the scope. It does not execute JavaScript array logic.