Abyss Web Server For Linux User's Guide
Prev | Chapter 7. eXtended Server Side Includes | Next

# Conditional blocks

## Syntax

Conditional blocks in XSSI look as follows:

       <!-- #if expr="test_expr_1" -->
               Content to process if test_expr_1 is true
       <!-- #elif expr="test_expr_2" -->
               Content to process if test_expr_2 is true
               .
               .
       <!-- #elif expr="test_expr_n" -->
       		Content to process if test_expr_n is true
       <!-- #else -->
       		Content to process if all the above tests are false
       <!-- #endif -->

`#elif` sections are optional. A conditional block can have zero or many of them. The `#else` is optional and a conditional block can have either no `#else` or exactly one.

Conditional blocks can be nested.

## Expression evaluation

The value of the `expr` attribute inside `#if` and `#elif` directives is considered as an expression which evaluates to true or false according to these rules:

string

  Evaluates to true if string is not empty.

string_1 `<` string_2, string_1 `<=` string_2, string_1 `>` string_2, string_1 `>=` string_2, string_1 `==` string_2

  Performs a lexicographic comparison between string_1 and string_2.

string_1 `=` string_2, string_1 `!=` string_2

  Performs a lexicographic comparison between string_1 and string_2. If string_2 has the form `/`regex`/`, a regular expression matching operation will take place instead. Matched sub-strings are captured inside the variables `$0`, `$1`, ..., `$9`. For more information about backreferences, refer to the "Regular Expressions" appendix.

test_expr_1 `&&` test_expr_2

  Evaluates to true if both test_expr_1 and test_expr_2 expressions are true.

test_expr_1 `||` test_expr_2

  Evaluates to true if at least one of the expressions test_expr_1 and test_expr_2 is true.

`!` test_expr

  Evaluates to true if test_expr is false.

`(` test_expr `)`

  Evaluates to true if test_expr is true. Parentheses are used to enclose sub-expressions and supersede the priorities of their operators.

`!` has higher priority than `&&` and `||` which at their turn have higher priority than `=`, `!=`, `==`, `<=`, `>=`, `<`, and `>`.

Prev | Home | Next
Directives | Up | Encoding

Copyright © 2001-2013 Aprelium